Search code examples
azurequeueazure-queues

Adding typed object to MessageQueue in Azure


I want to add a class to the MessageContent of a MessageQueue before adding it in QueueStorage.

Example

class udpates
{
    public int userId {get; set; }
    public Datetime UpdateTime {get; set; }
}


queue.addMessage("instance of updates class")

How can i do that ?

thanks,


Solution

  • Queue messages are either string or binary. You could serialize the object yourself and then enqueue the result.

    Personally, I prefer string-based queue messages, as I can easily debug issues by pulling messages from a queue and viewing them without needing to decode. Also, it's easy to update a queue message when it's a string.