3

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.
Saw
  • 6,199
  • 11
  • 53
  • 104

1 Answers1

3

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.

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • This option seems like putting it in dead letter queue. I would rather have this in the queue for other consumers to use. Is that possible? – user872858 Dec 03 '18 at 16:56
  • It shouldn't immediately dead letter the message, that would be the explicit [DeadLetter](https://learn.microsoft.com/en-us/dotnet/api/microsoft.servicebus.messaging.brokeredmessage.deadletter?view=azure-dotnet) method, **but** it does consume one of the delivery attempts on the message. I haven't been able to locate an API which doesn't consume a delivery attempt while still allowing me to PeekLock yet. – Stephen O Apr 15 '19 at 07:24