简体   繁体   中英

What serialization method is used for an ActiveMQ NMS C# object message?

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?

Does anyone have experience doing this with C# objects? Are there any pitfalls that you know of?

The default is System.Runtime.Serialization.Formatters.Binary.BinaryFormatter for IObjectMessage.

You can set your own by eg

IObjectMessage m = session.CreateObjectMessage();

((ActiveMQObjectMessage)m).Formatter=new SoapFormatter();//Or any IFormatter

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.

If you wish, you can also send/receive IByteMessage/ITextMessage and serialize your objects to the messages yourself in any way you'd like.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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