I have been reading through the documentation and looking at examples online and didn't find anything definitive. I'm wondering what the best practice might be if you want to send a Service Bus message but are only serialising and sending a small number of fields eg. 3.
I have the following Json to send in a message but was wondering whether I might as well not just add them as User properties.
So the Json for the message body is this:
{
"FbcId": 1845,
"FileId": "1d78d6ae-4005-48ac-9561-2533bf351d62",
"DateLastImported": "2020-10-18T20:25:59.5370965+01:00"
}
Would I be just as well constructing a message like this?
var message = new Message
{
Label = "Fbc Import"
};
message.ApplicationProperties.Add("FbcId", fbcId);
message.ApplicationProperties.Add("FileId", fileId);
message.ApplicationProperties.Add("DateLastImported", dateLastImported);
The body is usually some sort of serialized payload. Properties (or headers) are the metadata about the payload. What's important to remember is that messages going through topics/subscriptions can be filtered. And filtering can only be performed on the properties/headers (both, user and system properties). If the data needs to be deserialized, it's easier to have it in the payload (message body). And at the same time, anything from the payload could be used to help with message filtering by promoting the needed value into the properties.