Getting Started

MSMQ Dead Letter Queues

Component: MSMQ Transport
NuGet Package: NServiceBus.Transport.Msmq (1.x - 1.1)
Target Version: NServiceBus 7.x

Dead Letter Queues is a feature of MSMQ that tracks messages that are undeliverable, deleted, expired etc. NServiceBus endpoints will by default enable DLQ for all outgoing messages except messages that have a Time To Be Received(TTBR) set. This avoids expired messages ending up either in the TDLQ or DLQ (if non-transactional queues are used) wasting disk space on the machine when they time out.

DLQ can be disabled for the entire endpoint using the MSMQ connection string.

Enabling DLQ for messages with TTBR

In Versions 6.1 and below DLQ is be enabled by default for TTBR messages.

To opt-in to this behavior for Versions 6.2 and above, use:

var transport = endpointConfiguration.UseTransport<MsmqTransport>();

Monitoring DLQ

MSMQ moves messages that cannot be delivered to their destination to the DLQ. This may be due to misconfiguration of routing or queues being purged. See Dead-Letter Queues for a comprehensive list of conditions under which messages may be moved to the DLQ.

It is very important to monitor the DLQ in order to detect potential routing configuration errors or other situations that may lead to messages being moved to the dead-letter queue.

Reading messages from DLQ

The following addresses can be used to read messages from DLQ on a given machine:


Performance counters

The MSMQ Queue performance object contains counters that can be used to monitor the number of messages in various queues. Value of the Messages in Queue counter of the Computer Queues instance tracks the number of messages in the DLQ on a given machine.