Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between BrokeredMessage Body Vs message.Properties ?

I'm little confused between BrokeredMessage Body Vs message.Properties ?

I want to insert message into queue and based on message want to trigger Webjob

What is the Difference between BrokeredMessage Body Vs message.Properties ?

example

// Create message, passing a string message for the body
                BrokeredMessage message = new BrokeredMessage("Test message " + i);

                // Set some addtional custom app-specific properties
                message.Properties["EventId"] = i;

When I retrieve data from Queue

Console.WriteLine("Body: " + message.GetBody<string>());
                        Console.WriteLine("Test Property: " +
                           message.Properties["EventId"]);

Can any one elaborate more on difference ?

like image 425
Neo Avatar asked May 15 '26 21:05

Neo


1 Answers

Properties is a simple key-value pair collection. In most cases you can use it to send information if you can map them as key-value pair of course. Body is the payload of the message that can be empty if you send your information content using only Properties (as above). If you need to send data encoded in a specific application format (ex. JSON, XML, ...) you have to use the Body. The same is for sending binary data ... you need to use Body. The advantage of Body (using Azure SDK) is the serializing feature; you can serialize a business logic class (or from your model) in the Body using a serializer (JSON/XML).

Paolo

like image 51
ppatierno Avatar answered May 17 '26 17:05

ppatierno