【问题标题】:How can I write a query for notification request from application to Database?如何编写从应用程序到数据库的通知请求查询?
【发布时间】:2013-06-21 08:21:35
【问题描述】:

This is my perivous question。关于如何从数据库推送数据而不是应用程序拉数据。

经过link 和文件后,我知道我需要在应用程序端编写一个查询以获取通知请求,然后数据库将在订阅中注册我的请求,如果数据库有任何变化,它将检查订阅,如果有请求,它将向客户端发送消息。

此段来自上述链接

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.

现在我不知道如何在应用程序端为通知请求编写查询,并且我不理解上面给出的段落中的submit a service and a broker instance。我猜在查询数据库以获取通知请求之前,需要在应用程序中创建服务和代理实例。如果是这样,如何创建服务和代理实例?

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

【问题讨论】:

    标签: sql-server queue service-broker query-notifications


    【解决方案1】:

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

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

    服务代理是 SQL Server 的一个组件,您无需实例化或创建它。您启用它 - 这是一个 SQL Server 管理员任务来执行它。

    要创建一个新服务,您必须首先为它create queue 和一个contract 才能有一种通信方式。那你create your service

    当您创建服务时,实例化、激活和其他相关操作由 Service Broker 处理。

    【讨论】:

      猜你喜欢
      • 2021-12-27
      • 1970-01-01
      • 2012-01-31
      • 2020-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多