azureazure-storageazure-storage-queues

Getting duplicate messages from Azure Storage Queue


I am getting duplicate messages from Azure Storage Queue. I am sure that my function is getting executed only once as I am logging the message in the database in the same function. After clicking on the button, I see that, message is queued in storage queue and in a second its dequeued(so again, it's not like that there are 2 same messages enqueued).

Any thoughts on this? Thanks in advance!

P.S - please note that it's not a Azure Service Bus where I can set the property RequiresDuplicateDetection to True to fix this issue.


Solution

  • For now, azure Storage queues do not support Duplicate detection.

    There is no mechanism that can query a Storage queue and find out if a message with the same contents is already there or was there before. You can try to implement your own logic using some storage table, but that will not be reliable - as the entry into the table may succeed and then entry into the queue may fail - and now you would potentially have bad data in the table.

    Your code should always assume that it can retrieve a message containing the same data that was already processed. This is because messages can come back to the queue when workers that are working on them crash or take too long.

    As the storage queue does not support duplicate detection, you can give your voice to feedback.

    enter image description here

    For more details, you could refer to this article.