Mohamed Sakher Sawan Mohamed Sakher Sawan - 1 month ago 12
C# Question

Azure Service Bus Queue - Release locked message back to the queue

Is there a way to unlock a locked message in the queue before the timeout, so that it is available again to the queue (a way to change the lock timeout to a very small value would be good enough).

A similar functionality is available in AWS SQS, where there is (ChangeMessageVisibility) to change the lock timeout, if the timeout is set to a very small value, the message will be released back to the queue.

The call sequence:


  • Send the message from the producer: queueClient.SendAsync

  • Receive the message from the consumer: messageReceiver.ReceiveAsync

  • The consumer decided that they the message needs to be available again in the queue, this is the step I am asking for.


Answer Source

Is there a way to unlock a locked message in the queue before the timeout, so that it is available again to the queue

The method you're looking for is Abandon. This will release the message lock. From the documentation:

Abandons the lock on a peek-locked message.