Using Windows Services to process MSMQ messages via WCF

試著忘記壹切 提交于 2019-11-29 15:46:36

问题


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?

回答1:


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




回答2:


One way to transfer messages from an MSMQ to a web service call is to use a netMsmqBinding service endpoint and a basicHttpBinding client endpoint that support the same contract. The netMsmq service will automatically grab messages from the queue and deserialize them into an object. In your implementation of your netMsmq service, just instantiate your basicHttp client proxy and just call the same method. Basically a pass-through or proxy pattern from the web-service to the MSMQ and vice-versa. In Juval Lowy's "Programming WCF" he calls this pattern the "HTTP Bridge" for queues.



来源:https://stackoverflow.com/questions/372935/using-windows-services-to-process-msmq-messages-via-wcf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!