SQL 如何检查我的队列(服务代理)是否启用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25776047/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to check if my Queue (Service Broker) is enable or not?
提问by makitocode
rarely, for reasons that have not yet identified, my queue is disabled, when this happend, I enable again with this query:
很少,由于尚未确定的原因,我的队列被禁用,当发生这种情况时,我再次启用此查询:
ALTER QUEUE [MyQueue] WITH STATUS = ON;
but, i want to know when the queue is disabled, such as an event (T-SQL), or check each "x" time if queue is enabled.
但是,我想知道队列何时被禁用,例如事件(T-SQL),或者如果队列被启用,则检查每个“x”时间。
回答by Remus Rusanu
Look into sys.service_queues
:
select is_receive_enabled
from sys.service_queues
where name = N'MyQueue';
Your queue gets disabled by the poison message handling mechanism. When this happens an event is fired which can be captured via Event Notification, see Service Broker Application Queue Disable Event.
您的队列被有害消息处理机制禁用。发生这种情况时会触发一个事件,该事件可以通过事件通知捕获,请参阅Service Broker 应用程序队列禁用事件。