msmq单个队列中的多种消息类型 [英] msmq multiple message types in a single queue
问题描述
我打算让一个队列接收大约100种不同的消息类型.
I'm planning on having a single queue receive ~100 different message types.
如果我只有两种不同的类型,我会做类似的事情
If I had only had 2 different types I'd do something like this
MessageQueue队列=新的MessageQueue(_queue); queue.Formatter = new XmlMessageFormatter(new Type [] {typeof(CreateReportComand),typeof(CreateReportComand2)});
MessageQueue queue = new MessageQueue(_queue); queue.Formatter = new XmlMessageFormatter(new Type[] { typeof(CreateReportComand), typeof(CreateReportComand2)});
向XmlMessageFormatter传递约100个类型的数组是否疯狂.如果不是,检查收到的消息以确定如何处理的最佳方法是什么?
Is it craziness to pass XmlMessageFormatter an array of ~100 Types. And if not what is the best way to examine the received message to decide how to handle it?
推荐答案
您可以使用WCF MsmqIntegrationBinding
并处理MsmqMessage<string>
类型的消息.然后,您的处理程序方法将以字符串形式接收序列化的消息,然后可以用它来做您想做的事情.
You can use the WCF MsmqIntegrationBinding
and handle messages of type MsmqMessage<string>
. Then your handler method will receive the serialized message as a string and can do what you want with it after that.
这篇关于msmq单个队列中的多种消息类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!