简体   繁体   中英

How do I monitor the age of messages in SQL Service Broker?

I have a SQL Server 2008 Service Broker queue that processes messages by calling a CLR stored procedure (which, in turn, transports the messages via HTTP to a third party's REST API). I need to get a handle on "how backed up?" or "how far behind?" this queue is. While I understand that the total number of messages in the queue is a good indicator of progress, what I'm interested in is "how long was the most recently handled message waiting in the queue to be processed?" As best I can tell, selecting from the queue gives you all of the messages in it, but does not give the age of the message. For example:

SELECT TOP 100 *, casted_message_body = 
CASE message_type_name WHEN 'X' 
  THEN CAST(message_body AS NVARCHAR(MAX)) 
  ELSE message_body 
END 
FROM [SyncReadTargetQueue] WITH(NOLOCK)

But, none of the columns indicate age.

Any ideas?

To get the time when message arrived you could use "security_timestamp" in sys.conversation_endpoints .

How to monitor Service Broker- maybe this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM