Wcf – Using Windows Services to process MSMQ messages via WCF

msmqmsmq-wcfwcf

We have a solution where we are picking the messages using Windows Service.

The Windows Service fires every after 2 minutes and retrieves the MSMQ message to pass it to a Web Service.

  1. Can I create a WCF service which will automatically picks up the messages from MSMQ Queue?
  2. Can I avoid Windows Service by using WCF Service if it support auto invocation?

Best Answer

Q1: you can automatically pick up messages from MSMQ, you will need to look into the netmsmqbinding, there are some design considerations that you have to think about though, if you are used to the native MSMQ, you know that you have the ability to peek at the messages. But when you use WCF, you loose that ability to peek. WCF will intercept the messages in MSMQ and you are responsible for keeping your WCF service and the peeking app in synch. You will also need to look into whether you need transactional or non-transactional queues and you will have to modify your binding based on that.

Q2: You will need to host the WCF service in windows service or in IIS7. if you host in IIS7 look into enabling MSMQ WAS listener

Here is a nice article: http://blogs.msdn.com/tomholl/archive/2008/07/12/msmq-wcf-and-iis-getting-them-to-play-nice-part-1.aspx

Related Topic