sys.dm_broker_queue_monitors (Transact-SQL)

Applies to: SQL Server

Returns a row for each queue monitor in the instance. A queue monitor manages activation for a queue.

Column name Data type Description
database_id int Object identifier for the database that contains the queue that the monitor watches. NULLABLE.
queue_id int Object identifier for the queue that the monitor watches. NULLABLE.
state nvarchar(32) State of the monitor. NULLABLE. This is one of the following:



last_empty_rowset_time datetime Last time that a RECEIVE from the queue returned an empty result. NULLABLE.
last_activated_time datetime Last time that this queue monitor activated a stored procedure. NULLABLE.
tasks_waiting int Number of sessions that are currently waiting within a RECEIVE statement for this queue. NULLABLE.

Note: This number includes any session executing a receive statement, regardless of whether the queue monitor started the session. This is if you use WAITFOR together with RECEIVE. Basically, these tasks are waiting for messages to arrive on the queue.


Requires VIEW SERVER STATE permission on the server.

Permissions for SQL Server 2022 and later

Requires VIEW SERVER PERFORMANCE STATE permission on the server.


A. Current status queue monitor

This scenario provides the current status of all message queues.

SELECT AS [Service_Name], AS [Schema_Name], AS [Queue_Name],    
CASE WHEN t4.state IS NULL THEN 'Not available'   
ELSE t4.state   
END AS [Queue_State],    
CASE WHEN t4.tasks_waiting IS NULL THEN '--'   
ELSE CONVERT(VARCHAR, t4.tasks_waiting)   
END AS tasks_waiting,   
CASE WHEN t4.last_activated_time IS NULL THEN '--'   
ELSE CONVERT(varchar, t4.last_activated_time)   
END AS last_activated_time ,    
CASE WHEN t4.last_empty_rowset_time IS NULL THEN '--'   
ELSE CONVERT(varchar,t4.last_empty_rowset_time)   
END AS last_empty_rowset_time,   
FROM sys.transmission_queue t6   
WHERE (t6.from_service_name = ) AS [Tran_Message_Count]   
FROM t1    INNER JOIN sys.service_queues t2   
ON ( t1.service_queue_id = t2.object_id )     
INNER JOIN sys.schemas t3 ON ( t2.schema_id = t3.schema_id )    
LEFT OUTER JOIN sys.dm_broker_queue_monitors t4   
ON ( t2.object_id = t4.queue_id  AND t4.database_id = DB_ID() )    
INNER JOIN sys.databases t5 ON ( t5.database_id = DB_ID() );  

See Also

Dynamic Management Views and Functions (Transact-SQL)
Service Broker Related Dynamic Management Views (Transact-SQL)