集成 SQL Service Broker 和 NServiceBus
我的要求是我有不同状态的“项目”。我需要根据这些项目的状态执行各种不同的操作(发送电子邮件、存储文件、更新内部应用程序等)。问题是更新这些状态的应用程序是第三方的,所以我无法更新它;雪上加霜的是,只有一半的组织正在使用该系统,而另一半正在使用未来的替代系统。我确实可以开放访问所使用的两个数据库。
我的计划是通过 Item
表的每个表示上的触发器将带有 ID 和状态的消息添加到 SQL Service Broker 队列。然后,从 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 服务。我只是想要一些意见或建议。谢谢。
My requirement is that I have "items" with different states. I need to do all kinds of different things based on the states of these items (send emails, store files, update internal applications, etc). The problem is that the application that updates these statuses is third party, so I can't update it; furthering the difficulty is the fact that only half of the organization is using this system and the other are using it's future replacement. I do have open access to both of the databases used.
My plan is to add a message to a SQL Service Broker Queue with and ID and the status via a trigger on each representation of the Item
table. Then, call a CLR procedure from the SSB activation procedure that adds a message to a publish queue via NServiceBus.
This all seemed to be going well until I tried to register my assemblies in SQL with CREATE ASSEMBLY
:
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
First, I want to know if this is a completely crazy idea. I want the messages processed in order and added to the queues asynchronously. NServiceBus provides a host application that makes it very easy to spin up a new publishers when needed. The alternative seems to be to write a windows service that monitors the SSB queue and then publish. I'd just like some opinions or advice. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 NServiceBus-Contrib 中的 SSB 传输。
Take at look at the SSB Transport in NServiceBus-Contrib.
我可能会选择 Windows 服务轮询模型。尽管这并不令人兴奋并且引入了延迟,但至少您可以使一切变得美好且具有事务性,并且可以在易于理解的容器中处理故障。我不确定 sql-clr 在故障情况或重负载情况下如何执行。例如,您是否可以从服务代理中出队,然后丢失消息?
只是我的 2 美分
编辑
@Marco 向我指出了以下 MS 示例,用于将 SB 消息接收到 Windows 服务中:
http://code.msdn.microsoft.com/Service-Broker-Message-e81c4316
I would probably go with the windows service polling model. Even through this is non-exciting and introduces latency, at least you can make everything nice and transactional and can handle failures in a well-understood container. I am not sure how the sql-clr performs under failure conditions, or conditions of heavy load. For example, could you de-queue from the service broker and then lose the message?
Just my 2 cents
EDIT
@Marco pointed me to the following MS sample for receiving SB messages into a windows service:
http://code.msdn.microsoft.com/Service-Broker-Message-e81c4316