Reputation: 4107
There is a scenario in one of our continuous webjobs which has us a little puzzled. We have very thorough logging and the picture that it paints seems to indicate that two messages were dequeued by the same invocation of a webjob. The timestamps seem to support this. But more compelling was the exception.
At one point in our code we are adding a key to a dictionary. The exception that we observed was that a duplicate key was attempted to be added to that dictionary. If the 2 messages were dequeued at the same time by the same instance of the webjob method, then that is the only thing that seems to make sense. Because the dictionary is created with each invocation using the new keyword i.e. each invocation of the dequeue method creates a separate object in memory.
In short, my question is, can 2 messages be dequeued simultaneously by the same instance/method of a continuously running webjob which is observing that queue?
Upvotes: 0
Views: 172
Reputation: 4154
By default there is parallel execution so the ordering of the dequeued messages would be different. You can set the batchsize to 1 https://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-webjobs-sdk-storage-queues-how-to/#config
Upvotes: 1