Consuming MSMQ with WCF

New at MSMQ and WCF. I want to be able to process incoming MSMQ messages at a high rate. I want to make it Multithreaded (and transactional). What is the best way of doing this? Any examples, code snippets, theories are very much welcome. Also, how is WCF able to know if there is a message in the MSMQ? Or would I have to create a Windows Service that polls the MSMQ, then for messages found, start it on a new thread and invoke the WCF service and pass the message to it? What is the best way?

Many thanks


Answer here was to use WCF and create a data contract of service known types. These known types are objects it would be expecting from the queue being read from.

To make it multi threaded and transactional, not only does the queue need to be transactional but also decorate the service attribute:

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.PerSession, ReleaseServiceInstanceOnTransactionComplete = false)]    

The InstanceContextMode IS perSession by default.

you also need to set up the bindings on your config file

example: http://msdn.microsoft.com/en-us/library/ms751493.aspx

链接地址: http://www.djcxy.com/p/55810.html

上一篇: MSMQ和WCF合同

下一篇: 使用WCF消耗MSMQ