我開發和設計監控查詢至少3個BizTalk項目和它也覆蓋你的。在我展示實際查詢之前,我嘗試先解釋我的想法。
這個想法是儘可能多地使用BizTalk工件作爲一個同時具有端口狀態和消息傳遞狀態的結果表。通過這種方式,可以很容易地監控某件事實際上是否存在錯誤。港口地位相當簡單,因爲它只是一個選擇。消息狀態位於端口的一個實例上。首先我向您展示查詢的ERD。
在上面ERD你可以看到我的查詢中使用的所有表和字段,下面的圖片說明如何表一起使用:
現在在這裏,正在監視Sendports,接收位置和編排的查詢:
--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
在ab Ove查詢I將狀態映射到編號,對於我使用與BizTalk相同的消息傳遞狀態,對於端口狀態I,將Enabled和Disabled映射到4和5,以便我可以在同一列中看到接收位置狀態。
可能的消息傳遞狀態:
- 0:無
- 1:開始
- 2:已完成
- 3:終止
- 4:懸浮
- 5:準備運行
- 6:活性
- 8:脫水
- 16:已完成隨着丟棄的消息
- 32:懸浮非可恢復
- 64:在斷點
可能的端口狀態:
- 0:無
- 1:Unenlisted
- 2:停止
- 3:入門
- 4:啓用
- 5:禁用
非常好的答案 – OnTheFly
回答這個問題值得讚揚的努力! –