title: Azure Service Bus Serialization Type
body: <p>We've started investigating the use of the Windows Azure Service Bus as a replacement for our current queues as we move towards a service orientated architecture.</p>
  
  <p>Most of the documentation is clear; however I having a hard time ascertaining which type of serialization the <code>BrokeredMessage</code> uses when provided with a body.</p>
  
  <p>For example, let's say I instantiate a <code>BrokeredMessage</code> object as below:</p>
  
  <pre><code>ICommand sendMessageCommand = new SendMessageCommand
  {
      Title = "A new message title",
      Body = "A new message body"
  };
  
  BrokeredMessage brokeredMessage = new BrokeredMessage(sendMessageCommand);
  
  queueClient.Send(brokeredMessage); 
  </code></pre>
  
  <p><code>SendMessageCommand</code> is a simple DTO marked with the <code>[Serializable]</code> attribute; in our old queues this was binary serialized so it could be stored faster and have it's meta data preserved.  This is important to us as we use the queues to send commands using the <a href="https://cuttingedge.it/blogs/steven/pivot/entry.php?id=91">pattern outlined here</a> with the receiving Worker Role deserialzing the command with a mixture of generics and dynamic typing.</p>
  
  <p>However according to <a href="https://msdn.microsoft.com/en-us/library/windowsazure/hh694235.aspx">THIS</a> article the body passed in to the constructor of the <code>BrokeredMessage</code> is "Binary XML Serialized".  My assumption then is that this is standard XML serialization then passed through a binary formatter, is that correct?</p>
  
  <p>Further to this; does that mean that if I was to use the default <code>BrokeredMessage</code> message body functionality; I would have to ensure all objects are XML Serializable, inclusive of all the issues that presents? (Loss of private fields, no meta data for deserializing using generics, xml serialization attributes)</p>
  
  <p>Finally; if this is the case; is there a simple way around this? I was considering doing our own binary serialization then storing the <code>byte[]</code> in a property on the <code>BrokeredMessage</code>.</p>