Service Bus queues and topic subscriptions provide a secondary sub-queue, called a dead-letter queue (DLQ). The dead-letter queue does not need to be explicitly created and cannot be deleted or otherwise managed independent of the main entity. The purpose of the dead-letter queue is to hold messages that cannot be delivered to any receiver, or simply messages that could not be processed. Messages can then be removed from the DLQ and inspected.

Dead letter queues are the safest bet when we are using Azure Service Bus. If for whatever reason message could not be processed by a receiver, we could move such message to dead letter queue. This would mean, we may need manual intervention to determine why the message is not getting processed. Listener for the dead letter would just need to facilitate that by logging the message to some database or to a log file so that the user can take a look at that later.

In one of our project, we noticed that the cost for the service bus is not justifiable to the usage we had. We went on to find out the reason, that is when we noticed that we had many un-processed messages in the dead letter queue. We found Service Bus Explorer to be a very useful tool. Once we knew we had many un-processed messages in the queue, we knew it was the receiver which was not processing them. Every time a message was handed over to dead letter queue receiver,  that message was not processed. So Azure Service Bus kept on handing over the message and the receiver kept on rejecting the message. This explain the high cost for the service bus. Lesson learned was to make sure never to reject messages when the message is handed over to dead letter queue receiver.

Share on FacebookTweet about this on TwitterShare on LinkedInEmail this to someone
 
Share on FacebookTweet about this on TwitterShare on LinkedInEmail this to someone