0

I'm using the Microsoft.WindowsAzure.Storage.Queue library to push messages to an Storage Queue from an Azure Function with the following code:

public void Enqueue(MyMessage myMessage)
{
    string originalPayload = null;
    try
    {
          payload = serializer.Serialize(myMessage);
          var message = new CloudQueueMessage(payload);
          cloudQueue.AddMessage(message);
    }
    catch (Exception ex)
            {
                throw ex;
            }

}

This works for small volumes, but when processing around 200 messages per 5 minutes, almost half of the messages do not make it to the queue even though the function never fails and shows as successful for all attempts.

So I want to add a verification step after pushing the message and I was thinking if just a PopReceipt check would work:

if ( string.IsNullOrWhitespace(message.PopReceipt) )
{
    // the message was not added, do something
}
Velair
  • 227
  • 3
  • 12
  • more info here https://azure.microsoft.com/en-gb/blog/azure-storage-queues-new-feature-pop-receipt-on-add-message/ – Liam Jan 07 '21 at 14:01

1 Answers1

2

Yes, you can perform a verification check to determine whether the message was successfully added to the queue or not.

When constructing a CloudMessage var message = new CloudQueueMessage(payload); all other properties except AsString and AsBytes would be null. So you can use properties like "Id" or "PopReceipt" which are populated when the message is successfully added to queue to perform a verfication.

Also make sure whether your azure function gets triggered 200 times per 5 minutes as you mentioned, if your function is not triggered when the message arrives then the problem is with the azure function.

Balasubramaniam
  • 371
  • 5
  • 14