Sql server 如何编写从应用程序到数据库的通知请求查询?

Sql server 如何编写从应用程序到数据库的通知请求查询?,sql-server,queue,service-broker,query-notifications,Sql Server,Queue,Service Broker,Query Notifications,。关于如何从数据库中推送数据而不是应用程序拉取数据 在浏览了和文档之后,我知道我需要在应用程序端为通知请求编写查询,然后DB将在订阅中注册我的请求,如果DB中有任何更改,它将检查订阅,如果有请求,它将向客户端发送消息 本段来自上述链接 Along with the query submitted for the notification, the client submits a service name and a broker instance. Each notification subs

。关于如何从数据库中推送数据而不是应用程序拉取数据

在浏览了和文档之后,我知道我需要在应用程序端为通知请求编写查询,然后DB将在订阅中注册我的请求,如果DB中有任何更改,它将检查订阅,如果有请求,它将向客户端发送消息

本段来自上述链接

Along with the query submitted for the notification, the client submits a service name
and a broker instance. Each notification subscription begins a Service Broker dialog 
with this provided service and broker instance. When data is changed and the change 
would affect the result of the submitted query result, a message is sent on this   
dialog. By sending this message, the client is considered notified and the notification 
subscription is removed. If client desires to be notified on further changes, is  
supposed to subscribe again.
现在,我不知道如何在应用程序端为通知请求编写查询,也不理解上面给定的段落中的
提交服务和代理实例。我猜在查询数据库以获取通知请求之前,需要在应用程序中创建服务和代理实例。如果是这样,如何创建服务和代理实例


我可以通过sys.dm_qn_subscriptions
命令中的
select*检查数据库服务器的订阅。有人能帮我吗?

可能您对上一个问题的答案不完全理解,所以我将尝试澄清一些事情:

我想服务和代理实例需要在中创建 在查询数据库以获取通知请求之前应用程序。如果是 那么,如何创建服务和代理实例呢

ServiceBroker是SQLServer的一个组件,您不需要实例也不需要创建它。您可以启用它—这是一项SQL Server管理任务

要创建一个新的服务,你必须首先为它和一个有一种沟通方式。那你呢

创建服务时,实例、激活和其他相关操作由ServiceBroker处理