1

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

Amit Kaushal
  • 429
  • 1
  • 9
  • 25

1 Answers1

3

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.

Thorarins
  • 1,836
  • 16
  • 21
  • In my first doubt my main concern is that is it important to serialize the object before transferring it to message queue. Also, is this important that first entry from queue must be removed before accessing next entry – Amit Kaushal Sep 04 '15 at 07:51
  • you have to serialize in some way, since it is stored out of application scope. and it could be consumed by other technology than .net C# although that is not so common. – Thorarins Sep 04 '15 at 08:01
  • Thanks for your answers. Can you also guide me over second part of my last comment – Amit Kaushal Sep 04 '15 at 08:13
  • for the seconde part take a look at this http://stackoverflow.com/questions/11988572/msmq-receive-and-delete – Thorarins Sep 04 '15 at 08:21
  • I went through that link and also read in msdn documentation. To conclude, if you are using receive method with message queue instance you have read the message and message will be removed from queue and with peek method you are just reading the message. So, in former case, message is removed from queue and now you can access other message, but in later case, the message is not removed than how will you get other message – Amit Kaushal Sep 04 '15 at 08:35