我已经开始使用Service Broker。阅读文章https://www.itprotoday.com/sql-server/managing-service-broker-conversations之后,我尝试通过从sys.conversation_endpoints中选择现有会话来重用会话:
select top 1
@Handle = CEP.conversation_handle
from sys.conversation_endpoints CEP with(nolock)
where CEP.far_service = 'EventService'
and CEP.state = 'CO'
and CEP.is_initiator = 1
order by CEP.lifetime desc
并且在舞台上效果很好。但是在发布到正式版之后,发现选择sys.conversation_endpoints的问题-尽管有时在监视脚本中进行选择时有很多记录,但有时是空的,即使没有锁定也是如此。在Google呆了几个小时后,我找不到答案。请帮助我了解如何避免这种情况。
PS Microsoft SQL Server 2017(RTM-CU17)(KB4515579)-14.0.3238.1(X64)
问题出在调用我的存储过程的用户中,他没有查看某些元数据信息的权限。