{tocify} $title={Table of Contents}
Also there were 7K+ messages in the queue.
So if message is not processed, it will remain there for 10675198 days.
This forced the messages to be removed in 5 seconds - not all at once as it depends on Maximum Delivery Count property( It can also be changed).
Scenario
I was testing a logic app which is queue based . While testing found some changes to be done in the test data - did that and started the testing again.
But as the message volume of testing was high the earlier messages were still in queue and thus had to wait for old messages to get processed and the new ones to be picked.
To expedite the process started to Recieve and Delete individual messages via Service Bus explorer in Portal. But it was too laborious and time consuming.
Also there were 7K+ messages in the queue.
So the next thought was, why don't we have option to clear the queue using Portal?
Message time to Live(TTL)
One of the property of messages in Service Bus Queue is Message time to Live(TTL).
The expiration for any individual message can be controlled by setting the time-to-live i.e. it indicates a time span for which a message will live inside a queue.
If the message is not processed by that time, it will either be removed or dead-lettered.
Based On the Service Bus tier, the maximum ttl differs, minimum is 5 seconds
- For the basic tier, the default (also maximum) expiration time is 14 days.
- For Standard and Premium tier, the maximum expiration time is 10675199 days.
How to use Message time to Live(TTL) to clear service bus queue
Now, my need was to clear those messages as I wanted new set of messages to be tested.
The trick used here is to make the time to live to it's minimum - 5 seconds.
This forced the messages to be removed in 5 seconds - not all at once as it depends on Maximum Delivery Count property( It can also be changed).
In few minutes all messages were removed.
I again reset the TTL to maximum and pumped in new set of messages for testing.
Note: This is not recommended for Production.
If you know better way to clear the service bus message queue , you can share it in comments !!!
Do share if you find this helpful .......
Knowledge Sharing is Caring !!!!!!
Tags:
Azure Service Bus
Any suggestions for clearing Dead Letter Queue messages from Production env?
ReplyDeleteDid not work for me. Messages are still there.
ReplyDeleteDid not work for me either... messages are still there.
ReplyDeleteThank you!! Try waiting a bit extra. Worked for me, removed 10k messages
ReplyDelete