【问题标题】:Get all suspended instances for specific application in BizTalk获取 BizTalk 中特定应用程序的所有挂起实例
【发布时间】:2023-03-12 12:42:02
【问题描述】:

在 BizTalk Server 管理控制台中,您可以查询挂起的服务实例,然后按应用程序名称过滤它们。在没有 BTS 管理控制台的情况下,我需要这样的功能。

到目前为止,我已经创建了 Powershell 脚本来获取挂起的实例:

$array = Get-WmiObject MSBTS_ServiceInstance `
           -Namespace 'root\MicrosoftBizTalkServer' `
           -Filter '(ServiceClass = 4 or ServiceClass = 1) `
                 and (ServiceStatus = 4 or ServiceStatus = 16)' 
foreach ($element in $array)
{
    Write-Host $element.InstanceID "-" $element.HostName "-" `
                 $element.ServiceStatus "-" $element.ServiceClass
}

如果您运行此脚本,您将获得所有挂起的实例,但如何找出它们属于哪个应用程序?

任何使用 PowerShell、WMI 或 C# 的解决方案都适合我。

【问题讨论】:

    标签: powershell wmi biztalk


    【解决方案1】:

    我使用过 Microsoft.BizTalk.Operations 程序集...

    Add-Type -AssemblyName ('Microsoft.BizTalk.Operations, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL')
    $dbServer = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\BizTalk Server\3.0\Administration' 'MgmtDBServer').MgmtDBServer
    $dbName = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\BizTalk Server\3.0\Administration' 'MgmtDBName').MgmtDBName
    $bo = New-Object Microsoft.BizTalk.Operations.BizTalkOperations $dbServer, $dbName
    $serviceInstances = $bo.GetServiceInstances()
    
    $tgt = "DeploymentFramework.Samples.HelloWorld"
    foreach ($instance in $serviceInstances)
    {
        if ($instance.Application -ieq $tgt)
        {
            $completionStatus= $bo.TerminateInstance($instance.Id)
        }
    }
    

    一件事我还没有解决...Why does terminating a suspended (not resumable) service instance return Failed, yet it is terminated

    【讨论】:

    • 只是我的 2 美分:在此答案之前,我创建了自定义 MSBuIld 任务,该任务使用 WMI 来查找应用程序和挂起的消息 - 唯一的问题是我无法批量终止它们,因此需要很多时间在循环中一一终止它们
    【解决方案2】:

    应用程序名称属性不通过 MSBTS_ServiceInstance 类公开。我相信原因是,应用程序概念仅在 BizTalk 2006 中引入,而 WMI API 从 2004 年就出现了。

    恐怕,你唯一的选择就是直接进入数据库。

    【讨论】:

      【解决方案3】:

      什么版本的 BizTalk?

      这适用于 BizTalk 2010:

      $array = Get-WmiObject MSBTS_ServiceInstance `
                 -Namespace 'root\MicrosoftBizTalkServer' `
                 -Filter '(ServiceClass = 4 or ServiceClass = 1) ` 
                       and (ServiceStatus = 4 or ServiceStatus = 16)' 
      foreach ($element in $array)
      {
          Write-Host $element.ServiceName
      }
      

      【讨论】:

      • 它给了我服务名称,而不是应用程序(名称)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-12
      • 2014-11-11
      • 2011-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-24
      相关资源
      最近更新 更多