简体   繁体   English

WCF 与服务总线

[英]WCF vs Service Bus

We're in a tight spot at work and I need some clarity:我们在工作中处于紧张状态,我需要澄清一下:

Basically: We can use WCF to read/write to an MSMQ and get type safety on the objects we pass.基本上:我们可以使用 WCF 读取/写入 MSMQ 并获得我们传递的对象的类型安全性。

Alternative: We could use something like NService Bus to do the exact same thing.替代方案:我们可以使用 NService Bus 之类的东西来做同样的事情。

Now at my work we're all well versed in WCF, but none of us are well versed in using a Service Bus.现在,在我的工作中,我们都精通 WCF,但我们都不精通使用服务总线。

So could someone please help me with some pros/cons gains/losses for using WCF or NService Bus as right now it looks to me that it would be easier to use WCF (as long as we don't need advanced transactions etc)?所以有人可以帮助我了解使用 WCF 或 NService Bus 的一些利弊得失,因为现在在我看来使用 WCF 会更容易(只要我们不需要高级交易等)?

How easy would you estimate it would be to later change from WCF to NService Bus?您估计以后从 WCF 更改为 NService Bus 有多容易?

Kind regards亲切的问候

If all you want to do is push messages into MSMQ, you don't need either.如果您只想将消息推送到 MSMQ,那么您也不需要。

NServiceBus doesn't just enqueue messages. NServiceBus 不只是将消息排入队列。 Per NServiceBus service that you write, you can specify to which messages it subscribes and which it publishes.根据您编写的 NServiceBus 服务,您可以指定它订阅哪些消息以及发布哪些消息。 NServiceBus then takes care of the dispatching and delivering of the messages, using MSMQ as the transport mechanism.然后,NServiceBus 使用 MSMQ 作为传输机制来处理消息的分派和传递。

NServiceBus makes it easy this way for applications to just publish and subscribe to messages without requiring knowledge of where they come from, or when a service has moved to another server. NServiceBus 使应用程序可以通过这种方式轻松发布和订阅消息,而无需知道消息来自何处,或者服务何时移动到另一台服务器。

However, NServiceBus is not as easy to use as you might think, there is not a lot of good documentation available.但是,NServiceBus 并不像您想象的那么容易使用,没有很多好的文档可供使用。 It thus takes some time to plough through it.因此,它需要一些时间来克服它。

And since v2.5, you need a commercial license if you want to use it on more than one thread.从 v2.5 开始,如果您想在多个线程上使用它,则需要商业许可证。

As others have mentioned, I wouldn't use NServiceBus as a way to simply get messages onto a queue.正如其他人所提到的,我不会使用 NServiceBus 作为一种简单地将消息放入队列的方式。 As Roy says, NServiceBus is not trivial to implement.正如 Roy 所说,NServiceBus 的实现并非易事。 It's an architectural choice, not simply an implementation choice.这是一种架构选择,而不仅仅是一种实现选择。

However, when my team moved from a WCF solution to NServiceBus, we were very happy (after the learning curve).然而,当我的团队从 WCF 解决方案迁移到 NServiceBus 时,我们非常高兴(在学习曲线之后)。 One of the advantages is that the design of the system makes it harder to do the wrong thing.优点之一是系统的设计使得做错事变得更加困难。 That is to say, if something is hard to do in NServiceBus, then you are probably not thinking about the architecture the way you should (if you want an asynchronous, scalable, maintainable system).也就是说,如果在 NServiceBus 中很难做某事,那么您可能并没有按照您应该的方式考虑架构(如果您想要一个异步、可扩展、可维护的系统)。

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

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