Subscribe to msmq

How to subscribe to a queue in msmq using C #. Assuming that I have a client in the form of a win and you want to subscribe to the queue, every time a message comes into the queue, I would like the form to be notified about this. Any example. Thanks

+7
c # winforms msmq
source share
4 answers

You can also use WCF to subscribe to messages from the MSMQ queue and treat them as a service method in your WCF service.

Departure

+5
source share

You need to look at the types in the System.Messaging namespace.

There is full asynchronous support, so you can wait for a message without stopping your user interface (but you need to use Control.BeginInvoke to return to your interface, as usual, for asynchronous actions in WinForms).

MSDN has many examples, for example. Receive an asynchronous message .

+3
source share

Why not take a look at NServiceBus ?

It is a very stable and mature platform that is built on MSMQ and has a pub / sub right out of the box. Dead is easy to get started, and you don't need your hands dirty with WCF!

+1
source share

As suggested by @marc_s, you can use the WCF service, which can use the NetMSMQ or MSMQIntegrated binding to subscribe to messages in MSMQ.

If you do not want to enter the WCF service between the Winforms application and MSMQ, you need to create a polling mechanism to check in MSMQ for new messages.

0
source share

All Articles