views:

398

answers:

1

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?

+2  A: 

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

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.

nos
Any good info on the backward compatibility of the binary format? What happens with a removed/added field?
TheSoftwareJedi
Seems in practice(in my limited experience atleat) missing fileds just get their default values. This serialization has nothing to do with NMS/ActiveMQ though. There's lots of questions regarding serialization on stackoverflow, poke around those.
nos