【问题标题】:Integrating SQL Service Broker and NServiceBus集成 SQL Service Broker 和 NServiceBus
【发布时间】:2011-09-14 15:20:48
【问题描述】:

我的要求是我有不同状态的“项目”。我需要根据这些项目的状态做各种不同的事情(发送电子邮件、存储文件、更新内部应用程序等)。问题是更新这些状态的应用程序是第三方的,所以我不能更新它;进一步的困难是,只有一半的组织正在使用这个系统,而另一半正在使用它未来的替代品。我确实可以访问使用的两个数据库。

我的计划是通过Item 表的每个表示形式的触发器向 SQL Service Broker 队列添加一条消息,其中包含 ID 和状态。然后,从 SSB 激活过程调用 CLR 过程,通过 NServiceBus 将消息添加到发布队列。

这一切似乎都很顺利,直到我尝试使用CREATE ASSEMBLY 在 SQL 中注册我的程序集:

Msg 10327, Level 14, State 1, Line 1
Warning: The Microsoft .NET Framework assembly 'system.web, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a, processorarchitecture=x86.' you are registering is not fully tested in the SQL Server hosted environment and is not supported. In the future, if you upgrade or service this assembly or the .NET Framework, your CLR integration routine may stop working. Please refer SQL Server Books Online for more details.

etc. etc. etc.

CREATE ASSEMBLY for assembly 'System.Web' failed because assembly 'System.Web' is not authorized for PERMISSION_SET = UNSAFE.  The assembly is authorized when either of the following is true: the database owner (DBO) has UNSAFE ASSEMBLY permission and the database has the TRUSTWORTHY database property on; or the assembly is signed with a certificate or an asymmetric key that has a corresponding login with UNSAFE ASSEMBLY permission.
Msg 10301, Level 16, State 1, Line 2
Assembly 'log4net' references assembly 'system.web, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: 2(The system cannot find the file specified.)). Please load the referenced assembly into the current database and retry your request.
Msg 6218, Level 16, State 3, Line 3
CREATE ASSEMBLY for assembly 'NServiceBus.Core' failed because assembly 'NServiceBus.Core' failed verification. Check if the referenced assemblies are up-to-date and trusted (for external_access or unsafe) to execute in the database. CLR Verifier error messages if any will follow this message
Msg 6218, Level 16, State 3, Line 4
CREATE ASSEMBLY for assembly 'NServiceBus' failed because assembly 'NServiceBus' failed verification. Check if the referenced assemblies are up-to-date and trusted (for external_access or unsafe) to execute in the database. CLR Verifier error messages if any will follow this message

首先,我想知道这是否是一个完全疯狂的想法。我希望消息按顺序处理并异步添加到队列中。 NServiceBus 提供了一个主机应用程序,可以在需要时轻松启动新的发布者。另一种方法似乎是编写一个监视 SSB 队列然后发布的 Windows 服务。我只是想要一些意见或建议。谢谢。

【问题讨论】:

    标签: sql-server-2008 c#-4.0 nservicebus service-broker


    【解决方案1】:

    看看NServiceBus-Contrib中的SSB传输。

    【讨论】:

    【解决方案2】:

    我可能会选择 Windows 服务轮询模型。即使这并不令人兴奋并引入了延迟,至少您可以使一切变得美好和事务性,并且可以在一个易于理解的容器中处理故障。我不确定 sql-clr 在故障条件或重负载条件下如何执行。例如,您是否可以从服务代理中出列然后丢失消息?

    只要我的 2 美分

    编辑

    @Marco 向我指出了以下 MS 示例,用于将 SB 消息接收到 Windows 服务中: http://code.msdn.microsoft.com/Service-Broker-Message-e81c4316

    【讨论】:

    • NServiceBus 不会在那里引入延迟?
    • 不确定您的意思,但不是,除非 SQLSB 的 NServiceBus 实现在后台使用轮询。
    • 我对 SQLSB 了解不多,但我的印象是,从中检索消息的唯一方法是使用池(SQL 语句),毕竟它是一个基于队列的表,但我可能错了。
    • 可能还有其他方法。如果您查看 Oracle 数据库队列(也只是表),OTP.net 提供了您可以注册处理程序的事件。因此,当消息到达 oracle 队列时,将触发事件并执行处理程序。这是一个更好的解决方案,我希望任何实现都会做类似的事情。
    • 但是事件不会凭空出现,除非使用一些 COM 对象,也许支持回调,在 SQL Server 的情况下,我看不出他们如何使用除了池之外的任何东西.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-09
    • 2010-11-21
    • 1970-01-01
    • 2013-09-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多