简体   繁体   English

使用WCF消耗MSMQ

[英]Consuming MSMQ with WCF

New at MSMQ and WCF. MSMQ和WCF的新增功能。 I want to be able to process incoming MSMQ messages at a high rate. 我希望能够以高速率处理传入的MSMQ消息。 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? 另外,WCF如何知道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? 还是我必须创建一个轮询MSMQ的Windows服务,然后为找到的消息在新线程上启动它并调用WCF服务并将消息传递给它? What is the best way? 什么是最好的方法?

Many thanks 非常感谢

Answer here was to use WCF and create a data contract of service known types. 答案是使用WCF并创建服务已知类型的数据协定。 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. InstanceContextMode默认为perSession。

you also need to set up the bindings on your config file 您还需要在配置文件上设置绑定

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

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

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