The unit of transfer on Azure Queue storage is the CloudQueueMessage
Cloud messages carry the payload of the message (i.e. your object or entity graph) in a serialized string (e.g. xml
or json
) or serialized binary representation (byte[]
). You have serialization options such as:
The choice of payload serialization format will depend on what level of 'compactness' you need on the data, and the compatibility required by the technologies that downstream clients will be using.
Unless bandwidth and deserialization time is absolutely critical, I would recommend using Json
as a general starting point, given its widespread adoption, and it is easy to read serialized message payloads.
Messages are then published with a method such as AddMessageAsync and consumed by GetMessageAsync
For publishing, you will need to serialize your classes / entity graphs there are CloudQueueMessage constructor overloads which accept byte[]
or string
parameters representing the message payload.
CloudQueueMessage(byte[])
CloudQueueMessage(string)
Similarly, the consumer will need to deserialize the payload received, which can be retrieved via either:
Also see:
XmlSerialization example : Passing object messages in Azure Queue Storage