Search code examples
c#.netazure-queuesazure-storage-queuesazure-storage-account

Checking status of message insert to Azure Queue


I have 1 problem about Azure Queue. After insert 1 message to Azure Queue, how can I check this message have been inserted successful or not in my code (.net)?

My solution is checking number of message already storage in queue and check again after insert new message queue. I try to find another solution. Thank for helping me


Solution

  • Update:

    The design of method 'AddMessageAsync' in Microsoft.WindowsAzure.Storage.Queue is like this:

    public virtual Task AddMessageAsync(CloudQueueMessage message);

    It returns nothing, so you have two ways:

    The first one is like you says, get the number of the messages in queue and check after Add message.

    The second one is put the logic in the try-catch, return exception if add message not success.

    Original Answer:

    Have a look of this API reference:

    https://learn.microsoft.com/en-us/dotnet/api/azure.storage.queues.queueclient.sendmessage?view=azure-dotnet

    The return type of the sendmessage method is response, so I think you don't need to get the number of the messages. Just check the response status is OK.