Skip Navigation LinksAzure Developers Guide > Azure Service Bus > Brokered Messaging > Brokered Messaging Features & Patterns > Deadlettering > Deadlettering in Service Bus Brokered Messaging

Training Courses

All course material is in English, and courses are delivered in English. Feel free to contact me for further information.

Deadlettering in Service Bus Brokered Messaging

In Service Bus brokered messaging both the dead letter channel pattern and the invalid message channel pattern are implemented on queues and subscriptions using deadletter sub-queues.

Messages are placed on the deadletter sub-queue by the messaging system in the following scenarios.

·        When a message expires and deadlettering for expired messages is set to true in a queue or subscription.

·        When the max delivery count for a message is exceeded on a queue or subscription.

·        When a filter evaluation exception occurs in a subscription and deadlettering is enabled on filter evaluation exceptions.

Receiving applications can also explicitly deadletter messages that have been received using the peek-lock receive mode by calling the Deadletter method on the Brokered message class, or client class. Once placed on the deadletter sub-queue the messages can be received by creating a QueueClient or MessageReceiver using the path for the deadletter sub-queue.

Deadletter Sub-Queues

Service Bus brokered messaging uses the prefix of $DeadLetterQueue for the path of the deadletter queues on topics and subscriptions. The deadletter sub-queue for the OrderQueue queue in the illustration will have the following path:





The deadletter sub-queues for the two subscriptions on the OrderTopic are as follows:






The QueueClient and SubscriptionClient classes provide a static FormatDeadLetterPath method for returning the paths for the deadletter sub-queues for queues and subscriptions. The following code will get the appropriate paths.


// Get the deadletter sub-queue path for the OrderQueue

string queueDeadletterPath = QueueClient.FormatDeadLetterPath("OrderQueue");


// Get the deadletter sub-queue path for the UKSubscription on the OrderTopic

string subDeadletterPath =

    SubscriptionClient.FormatDeadLetterPath("OrderTopic", "UKSubscription");



Speaking Engagements