4

有没有人写过查询来一次监控所有 BizTalk 工件。

我的查询不起作用,我似乎无法完成它:

这是我的:

select
    RL.Name AS rlName
    , ('Url: ' + RL.InboundTransportURL + ' | Receiveport: ' + RP.nvcName) AS rlDescription
    , RL.Disabled AS rlStatus
    , RL.uidCustomCfgID as uidGuid
from BizTalkMgmtDb.dbo.adm_ReceiveLocation AS RL WITH(READPAST, ROWLOCK)
    left join BizTalkMgmtDb.dbo.bts_receiveport AS RP WITH(READPAST, ROWLOCK)
        ON RL.ReceivePortId = RP.nID
--Readpast and Rowlock are needed to avoid lock escalation.
4

2 回答 2

7

我为至少 3 个 BizTalk 工件开发并设计了一个监控查询,它也涵盖了您的。在显示实际查询之前,我尝试先解释我的想法。

这个想法是尽可能多地使用 BizTalk 工件,作为一个包含端口状态和消息传递状态的结果表。通过这种方式,很容易监控是否确实有问题。端口状态相当简单,因为它只是一个选择。消息传递状态是在一个端口的实例上。首先,我向您展示查询的 ERD。

我与选定值一起使用的表的 ERD

在上面的 ERD 中,您可以看到我的查询中使用的所有表和字段,下图中解释了这些表是如何一起使用的:

表解释

现在是监控发送端口、接收位置和编排的查询:

--sendports, receive locations and orchestrations combined into one query
Declare @PortStatus as bigint  = null
Declare @MessagingStatus as bigint  = null
Declare @Name as Varchar(500) = null
Declare @Type as Varchar(500) = null
Declare @UniqueID as Varchar(500) = null 

;with combined as 
(
     (
        select s.uidGUID as uidGuid, s.nvcName AS Name, nPortStatus as PortStatus, 'SENDPORT' as [Type], nvcDescription as Description
        from dbo.[bts_sendport] AS s
     )
     union all
     (  
        select o.uidGUID as uidGuid, o.nvcName AS Name, nOrchestrationStatus as PortStatus, 'ORCHESTRATION' as [Type], nvcDescription as Description
        from dbo.[bts_Orchestration] AS o
     )
     union all
     (
        select
        RL.uidCustomCfgID as UniqueKey, RL.Name AS Name,
        CASE WHEN RL.Disabled = 0 THEN 4 ELSE 5 END as [PortStatus],
        'RECEIVELOCATION' as [Type]
        , ('Url: ' + RL.InboundTransportURL + ' | Receiveport: ' + RP.nvcName) as Description
        from BizTalkMgmtDb.dbo.adm_ReceiveLocation AS RL WITH(READPAST, ROWLOCK)
        left join BizTalkMgmtDb.dbo.bts_receiveport AS RP WITH(READPAST, ROWLOCK)
        ON RL.ReceivePortId = RP.nID 
     )
)

select uidGuid as UniqueKey, Name, Description,
CASE WHEN i.nState is NULL THEN 0 ELSE COUNT(*) END as [MessageCount],
[Type], i.nState as MessagingStatus, c.PortStatus
from [BizTalkMsgboxDb].dbo.[Instances] AS i WITH (NOLOCK)
    right join combined c ON i.uidServiceID = c.uidGuid
    WHERE 
    (@Type is null OR [Type] like '%' + @Type + '%') 
    AND uidGuid = COALESCE(@UniqueID, uidGuid) 
group by uidGUID, Name, i.nState, [Type], c.PortStatus, Description
having  c.PortStatus = COALESCE(@PortStatus, c.PortStatus) 
    AND (@MessagingStatus is NULL OR i.nState = @MessagingStatus) 
order by [Type], c.PortStatus, i.nState

在上面的查询中,我将状态映射到数字,对于消息状态,我使用与 BizTalk 相同的状态,对于端口状态,我将启用和禁用映射到 4 和 5,因此我可以在同一列中看到接收位置状态

可能的消息状态:

  • 0:无
  • 1:开始
  • 2:完成
  • 3:终止
  • 4:暂停
  • 5:准备运行
  • 6:活跃
  • 8:脱水
  • 16:已完成,但有丢弃的消息
  • 32:暂停不可恢复
  • 64:在断点

可能的端口状态:

  • 0:无
  • 1:未入伍
  • 2:停止
  • 3:开始
  • 4:启用
  • 5:禁用
于 2013-08-02T14:57:40.083 回答
0

您可以参考下面的文章,它解释了如何跟踪所有主机实例并在停止时启动它们。相同的技术可以应用于其他 BizTalk 工件。: http ://social.technet.microsoft.com/wiki/contents/articles/17835.biztalk-monitoring-and-automatically-starting-host-instances-via-a-计划任务.aspx

于 2013-08-08T09:53:39.983 回答