简体   繁体   English

基于.NET MSMQ的同步系统的体系结构

[英]Architecture of .NET MSMQ-based synchronization system

I have a straightforward, existing ASP.NET MVC web solution. 我有一个简单易用的现有ASP.NET MVC Web解决方案。 The server-based stuff writes information to a database. 基于服务器的内容将信息写入数据库。 I am now going to integrate/synchronize this system with a number of other 3rd-party systems. 现在,我要将此系统与其他许多第三方系统集成/同步。 I want to separate the integration processing from the existing core processing, leaving the existing system as untouched as possible. 我想将集成处理与现有核心处理分开,使现有系统尽可能保持不变。

My plan is as follows: 我的计划如下:

  1. whenever a database write occurs on the core system server I will write a message to an MSMQ Queue. 每当在核心系统服务器上发生数据库写操作时,我都会向MSMQ队列写一条消息。
  2. an entirely separate server-based windows service will poll the MSMQ, look at the message and will write messages to one or more 'outbound' sync MSMQ queues. 一个完全独立的基于服务器的Windows服务将轮询MSMQ,查看消息并将消息写入一个或多个“出站”同步MSMQ队列。
  3. other windows services will monitor the 'outbound' sync queues, and will talk to the 3rd-party systems as necessary, managing the outbound synchronization. 其他Windows服务将监视“出站”同步队列,并在必要时与第三方系统进行通信,以管理出站同步。

I have a couple of questions: Should I have a single windows service doing all this, or should I have several services, one central 'routing' one and one for each 3rd-party system? 我有几个问题:我应该只用一个Windows服务来完成所有这些工作,还是应该有几个服务,一个中央“路由”服务,每个第三方系统一个服务? Should I use WCF for any of this. 我应该使用WCF进行任何此类操作。 Does that buy me anything, given that the 'trigger' for writing to the initial queue is already 'happening' on a server-based process? 考虑到用于写入初始队列的“触发”已经在基于服务器的进程中“发生”,那对我有什么帮助?

Thanks very much. 非常感谢。

First, a separate windows service is always safer than any attempt to integrate this with your asp.net runtime. 首先,单独的Windows服务总是比任何将其与asp.net运行时集成的尝试都更安全。

Second, do not write anything by yourself. 其次,不要自己写任何东西。 Use 采用

http://code.google.com/p/masstransit/ http://code.google.com/p/masstransit/

It is straightforward and does everything you need. 它很简单,可以满足您的所有需求。 Reference the library from their nuget package, read some tutorials and you will love it. 从他们的nuget包中引用该库,阅读一些教程,您会喜欢它的。

To answer your questions: 要回答您的问题:

Should I have a single windows service doing all this 我应该只有一个Windows服务来完成所有这些工作吗

Definitely not. 当然不。 What if you want to scale out the routing service, or relocate it? 如果要扩展路由服务或将其迁移,该怎么办?

Should I use WCF 我应该使用WCF吗

If you have your heart set on msmq then the only advantage WCF gives you is it provides a convenient, proven way to design and host your service endpoints, and an alternative to mucking around in System.Messaging. 如果您对msmq有所了解,那么WCF的唯一好处就是它提供了一种方便的,行之有效的方法来设计和托管服务端点,并且是在System.Messaging中进行处理的替代方法。 I would say at this stage it doesn't matter that much. 我想说,在此阶段没什么大不了的。

Does that buy me anything 那买什么东西吗

Not sure what you mean, but as Wiktor says in his post, you could chose not to use vanilla .Net or WCF and choose a service bus type framework such as masstransit or nservicebus. 不确定您的意思,但是正如Wiktor在他的帖子中所说,您可以选择不使用vanilla .Net或WCF,而选择诸如masstransit或nservicebus之类的服务总线类型框架。

The benefit here is it abstracts you away from the messaging sub-system so you could in theory move away from msmq in the future to rabbitmq or azure queues. 这样做的好处是,它使您脱离了消息传递子系统,因此理论上您将来可以从msmq转移到Rabbitmq或Azure队列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM