什么序列化方法被用于一个ActiveMQ的网管系统C#对象消息? [英] What serialization method is used for an ActiveMQ NMS C# object message?
问题描述
我打算使用Apache网管进行ActiveMQ的消息,并想知道什么序列化方法将是对我送的对象使用呢? XML /二进制?什么控制序列化,我怎么可以自定义的呢?
I'm planning on using Apache NMS for ActiveMQ messaging, and am wondering what serialization method is going to be used on the objects I send? XML/Binary? What controls the serialization and how can I customize it?
没有人有经验与C#对象这样做呢?是否有你知道的任何陷阱?
Does anyone have experience doing this with C# objects? Are there any pitfalls that you know of?
推荐答案
默认为System.Runtime.Serialization.Formatters.Binary.BinaryFormatter为IObjectMessage。
The default is System.Runtime.Serialization.Formatters.Binary.BinaryFormatter for IObjectMessage.
您可以设置自己的,通过例如
You can set your own by e.g.
IObjectMessage m = session.CreateObjectMessage();
((ActiveMQObjectMessage)m).Formatter=new SoapFormatter();//Or any IFormatter
您会需要访问IObjectMessage.Body在接收端,如果你不使用默认的BinaryFormatter发送对象前设置格式。
You'd need to set the formatter before accessing IObjectMessage.Body on the receiver side if you're not sending objects with the default BinaryFormatter.
如果你愿意,你也可以在任何你想发送/接收IByteMessage / ITextMessage和序列化对象的消息吧。
If you wish, you can also send/receive IByteMessage/ITextMessage and serialize your objects to the messages yourself in any way you'd like.
这篇关于什么序列化方法被用于一个ActiveMQ的网管系统C#对象消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!