2

When you post a message to an Azure Queue how do you tell if the message was successfully posted?

When Using the following code:

queue.AddMessage(message);

We have found that in some situations the message is not posted to the queue. Looking at the documentation I can see that there is no exception thrown if the posting of the message was unsuccessful. What is the best way to check if the message posting failed?

Aran Mulholland
  • 23,555
  • 29
  • 141
  • 228

1 Answers1

1

Normally you should see an error in case the message is not written to the queue. However one thing you could do is check message id, insertion, expiration time properties of the message as they will be populated by the SDK once the message is successfully inserted.

From the documentation link:

The CloudQueueMessage message passed in will be populated with the pop receipt, message ID, and the insertion/expiration time.

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • 2
    Note that those fields of CloudQueueMessage will be populated after calling AddMessage only on version 8.0 or later of the storage client library. – Michael Roberson - MSFT May 02 '17 at 14:44
  • There is nothing in the documentation to say that an exception will be thrown if the message has failed to be placed in the queue. However checking the insertion time seems to be an acceptable solution to this problem. Thank you. – Aran Mulholland May 02 '17 at 15:50