简体   繁体   English

WCF反序列化来自MSMQ的消息

[英]WCF deserialize messages from MSMQ

I have a scenario where we will be getting 10-15 different XML messages enqueued to a message queue. 我有一个场景,我们将10-15条不同的XML消息排队到消息队列中。 All of the examples I have found depicting messages via WCF from an Queue show using "typeof - object" to deserialize the message. 我发现的所有示例都使用“ typeof-object”对消息进行反序列化,从而从队列显示中通过WCF描述消息。 However, in our case we will have a lot of different messages residing i the queue so simply trying to set a specific type won't work. 但是,在我们的情况下,队列中会驻留许多不同的消息,因此仅尝试设置特定类型将无法工作。 How are others handling a similar type of scenario where there are numerous types of messages? 其他人如何处理消息类型众多的类似情况?

Each message will have a <MessageHeader> and a <MessageBody> , but inside the body the payloads will be different for each message type. 每个消息将具有<MessageHeader><MessageBody> ,但是在主体内部,每种消息类型的有效负载将有所不同。

Any suggestions would be greatly appreciated. 任何建议将不胜感激。

You can use the WCF MsmqIntegrationBinding and handle messages of type MsmqMessage<string> . 您可以使用WCF MsmqIntegrationBinding并处理MsmqMessage<string>类型的消息。 Then your handler method will receive the serialized message as a string and can do what you want with it after that. 然后,您的处理程序方法将以字符串形式接收序列化的消息,然后可以对其执行所需的操作。

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

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