← Return To Home

Azure Service Bus Dead-Letter Queues

What is the Azure Service Bus Queue?

Queues are a very common piece of infrastructure. It offers First In, First Out (FIFO) message delivery to one or more competing consumers. As the queue grows the last item added to the queue typically must wait longer to be processed. Just like someone waiting in line to order food, the first one in line gets to order first. Microsoft Azure Service Bus (ASB) is Microsoft’s premier enterprise-level messaging technology that uses this principle of FIFO.

Types of Queues:

  • Primary queue, called main queue or active queue.
  • Secondary sub-queue, called a dead-letter queue(DLQ). 

Main Queue

ASB queues always have two parties involved-a producer and a consumer. The producer pushes the messages into the queue, while the consumer periodically polls for messages and consumes them. The main queue holds the messages until it is consumed or moved to dead-letter queue.

Azure Service Bus Dead Letter Queues

The purpose of the dead-letter queue is to hold messages that cannot be delivered to any receiver, or messages that could not be processed

The DLQ is mostly like any other queue, except that messages can only be submitted via the dead-letter operation of the parent entity. In addition, time-to-live is not observed, and you can’t dead-letter a message from a DLQ. The dead-letter queue fully supports peek-lock delivery and transactional operations. There is no automatic clean-up of the DLQ. Messages remain in the DLQ until you explicitly retrieve them from the DLQ.

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.

Dead letter queue(DLQ)

Dead-Letter Queue Reasons

Queued messages can fail delivery. These failed messages are recorded in a dead-letter queue. The failed delivery can be caused by reasons such as network failures, a deleted queue, a full queue, authentication failure, or a failure to deliver on time.

As the messages are moved from Active queue to dead-Letter, two properties DeadLetterReason and DeadLetterErrorDescription are added to the message.


Maximum header size: 64 KB. Incoming messages that exceed these quotas are moved to DeadLetter Queue, with DeadLetter reason code as ‘HeaderSizeExceeded’.

Errors on processing subscription rules

When the SubscriptionDescription.EnableDeadLetteringOnFilterEvaluationExceptions property is enabled for a subscription, any errors that occur while a subscription’s SQL filter rule executes are captured in the DLQ along with the offending message.

Exceeding TimeToLive

When the QueueDescription.EnableDeadLetteringOnMessageExpiration or SubscriptionDescription.EnableDeadLetteringOnMessageExpiration property is set to true (the default is false), all expiring messages are moved to the DLQ with the ‘TTLExpiredException’ reason code.so the messages have to be picked by the receiver before its expiry time in order to avoid entering into DLQ with TTLExpiredException.


When the QueueDescription.RequiresSession or  SubscriptionDescription.RequiresSession  property is set to true (the default is false), all messages without session ID are moved to the DLQ with the ‘Session id null’ reason code.

Application-level dead-lettering

In addition to the system-provided dead-lettering features, applications can use the DLQ to explicitly reject unacceptable messages. This can include

  • Messages that cannot be properly processed due to any sort of system issue
  • Messages that hold malformed payloads
  • Messages that fail authentication when some message-level security scheme is used

Exceeding MaxDeliveryCount

Queues and subscriptions each have a QueueDescription.MaxDeliveryCount and SubscriptionDescription.MaxDeliveryCount property respectively; the default value is 10. Whenever a message has been delivered under a lock (ReceiveMode.PeekLock), but has been either explicitly abandoned or the lock has expired, the message  BrokeredMessage.DeliveryCount is incremented. When DeliveryCount exceeds MaxDeliveryCount, the message is moved to the DLQ, specifying the ‘MaxDeliveryCountExceeded’ reason code. This behavior cannot be disabled, but you can set MaxDeliveryCount to a very large number. You could specify the Maximum Delivery Count between 1 and 2147483647.

Serverless360 helps to retrieve and resubmit the dead-lettered messages in a much smart way.

Real-time scenario

Consider an E-Commerce website where a customer will place an order. The order message will contain data like Order Id, Product Name, User Id, Address, etc. This order message will be sent to the Azure Service Bus Queue for a client application to process. Here Logic App acts as a client that picks up the message from the Service Bus Queue for validation. There might be a case that the Logic App would go down or there might be any failure which makes the Logic App disabled. The messages inside the service bus queue will be moved to the dead letter queue when it reaches the “Time to Live” a threshold value of the queue.

Resubmitting the dead lettered messages using Serverless360

Serverless360 has made this very simple, after associating the Queue within the Serverless360 Composite Application, follow the below steps to retrieve and resubmit the messages.

  1. Click the queue whose dead letter messages must be processed, this will lead to a message retrieval dashboard.
  2. Select dead letter tab and click get a specified count of messages 1-Resubmit the dead lettered messages using Serverless360
  3. Select those messages to be resubmitted and click resubmit 2-Resubmit the dead lettered messages using Serverless3602
  4. Select the destination Queue and proceed to resubmit 3-Resubmit the dead lettered messages using Serverless360
  5. The messages can also be repaired and resubmitted 4-Resubmit the dead lettered messages using Serverless360
  6. The user can also view the properties, content and dead letter reason of a message 5-Resubmit the dead lettered messages using Serverless360


I hope this blog gave a better understanding of Azure Service Bus Dead Letter Queue, the reason behind a message getting dead lettered. We also discussed on how Serverless360 can help to process Dead letter messages much smarter way.

Also, check how to Resubmit and Delete Dead-letter Messages of Queues and Topic Subscriptions blog for more insights.

Author: Priya Latha

Priya Latha is a Jr.Software Engineer at Kovai.co. She loves working with Angular, . Net and on Serverless technologies. She believes in the quote that "Expect nothing less than perfect".

One thought on “Azure Service Bus Dead-Letter Queues”

Comments are closed.