简体   繁体   English

订阅msmq

[英]subscribe to msmq

How to a subscribe to a queue in msmq using c#. 如何使用c#在msmq中订阅队列。 Assuming i have a client as a win form and would like to subscribe to a que, everytime a message is arrived in the que i would like the form to be notified about it. 假设我有一个客户作为胜利形式,并且想订阅一个阙,每当消息到达阙时,我希望表格得到通知。 Any example. 任何例子。 Thanks 谢谢

You could also use WCF to subscribe to messages from an MSMQ queue and handle them as a service method in your WCF service. 您还可以使用WCF订阅来自MSMQ队列的消息,并将它们作为WCF服务中的服务方法处理。

Check out 查看

You need to look at the types in namespace System.Messaging . 您需要查看名称空间System.Messaging中的类型。

There is full asynchronous support, so you can wait on a message arriving without halting your UI (but you'll need to use Control.BeginInvoke to call back into your UI as normal for asynchronous actions in WinForms). 有完全异步支持,所以你可以等到一个消息到达而不停止你的UI(但你需要使用Control.BeginInvoke回调到你的UI正常的WinForms中的异步操作)。

MSDN has plenty of examples, eg of an asynchronous message receive . MSDN有很多例子,例如异步消息接收

Why not take a look at NServiceBus ? 为什么不看看NServiceBus

It's a very stable and mature platform that is built on MSMQ, and has pub/sub right out of the box. 它是一个非常稳定和成熟的平台,建立在MSMQ之上,并且开箱即用。 Dead easy to get started with, and no need to get your hands dirty with WCF! 死了很容易上手,而且不需要用WCF弄脏你的手!

As suggested by @marc_s you can use WCF service which can use either NetMSMQ or MSMQIntegrated binding to subscribe to messages in the MSMQ. 正如@marc_s所建议的那样,您可以使用WCF服务,该服务可以使用NetMSMQ或MSMQIntegrated绑定来订阅MSMQ中的消息。

If you don't want to introduce WCF service between the Winforms application and the MSMQ, you'll need to build a polling mechanism to check into MSMQ for arrival of new messages. 如果您不想在Winforms应用程序和MSMQ之间引入WCF服务,则需要构建轮询机制以检查MSMQ是否有新消息到达。

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

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