Search code examples
c#.netsystem.messaging

serialize objects to transfer into the messagequeue instance


I was going through the msdn post of system.messaging namespace and come across a doubt about object serialization. I want to know that is it always important to that object must be xmlserializable in order to be transferred over a MessageQueue instance.

Second, if we are invoking the MessageQueue.Send member is this also means that we are using default System.Messaging.XmlMessageFormatter.

An explanation would be appreciative.

Thanks


Solution

  • you don't have to use xml, you can use BinaryMessage like this

       BinaryMessageFormatter formatter = new BinaryMessageFormatter();
       System.Messaging.Message message = new System.Messaging.Message(YourObject, formatter);
    

    second, xml message is the default, although I have always used binary, xml is to bulky for almost all kind of scenarios.