azureazureservicebusazure-webjobs

Same Message received multiple time in Azure Web Job from Azure Service Bus


I have a Azure Service Bus running. Whenever a new message is populated in the Queue , it is sent to the Azure Service Bus Web Job. I see that the same message appears multiple times and some times gives an error msg like this.

The lock supplied is invalid. Either the lock expired, or the message has already been removed from the queue. azure web job service bus

What is the reason behind and how this can be resolved?


Solution

  • This error indicated that the work performed in the webjob is taking longer than the configured lock time the message is given for. There's a property on the queue, MaxLockDuration which is by default 60 seconds and cannot exceed 5 minutes. Either you need to increase lock duration on the queue if processing can be completed within 5 minutes or change the way you handle the messages. One of the options would be to re-new lock, though I would not advise to go that route as it's not a guaranteed operation.