Dead Letter Queues

Dead letter queues are used for storing messages that could not be delivered. MSMQ provides a dead letter queue for non-transaction messages (DEADLETTER) and a dead letter queue for transaction messages (DEADXACT). Both types of queues are created by MSMQ whenever a computer is added to the enterprise.

Note  Only one copy of a message is stored on a computer at one time. If the message reached the next computer successfully, a copy of the message is stored in that computer's journal queue. If the message could not be delivered to the next computer, it is stored in the current computer's dead letter queue.

Non-transaction Messages and Dead Letter Queues

To use the non-transaction dead letter queue (DEADLETTER), the non-transaction message must have its journal property set to the appropriate value before the message is sent. Although the DEADLETTER queue is automatically created, MSMQ does not automatically send undelivered non-transaction messages to a computer's DEADLETTER queue.

MSMQ sends undelivered messages to the DEADLETTER queue of the computer that could not send the message. This can be the source computer, the destination computer, or any MSMQ routing server in between. When an undelivered message is placed in a DEADLETTER queue, MSMQ sets the message's class property to the appropriate negative acknowledgment.

Note  Only one copy of a message is stored on a computer at one time. If the message reached the next computer successfully, a copy of the message is stored in that computer's journal queue. If the message could not be delivered to the next computer, it is stored in the current computer's DEADLETTER queue.

Transaction Messages and Dead Letter Queues

The transaction dead letter queue (DEADXACT) is used regardless of the transaction message's journal property. MSMQ automatically places a copy of each transaction message it sends in the source computer's DEADXACT queue. The class of the stored message reflects the last known status of the message.

For example, MSMQ changes the class of the message if the message's time-to-reach-queue timer or time-to-be-received timer expires.

Only after receiving a positive acknowledgment does MSMQ remove the copy of the transaction message from the DEADXACT queue. Testing to see if the message is removed from the DEADXACT queue is the only way the sending application can tell that the receiving application committed to its transaction.

For information on… See…
Setting a message's journal property using the C API PROPID_M_JOURNAL
Setting a message's journal property using the ActiveX components Journal

Opening a Dead Letter Queue

To read the messages in the dead letter queue (an application cannot send messages to a dead letter queue) the format name used to open the queue should appear as follows:

MACHINE=MachineGUID;DEADLETTER (for non-transaction messages)
-or-
MACHINE=MachineGUID;DEADXACT (for transaction messages)
 

Note  You cannot open these queues using a direct format name.

For an example of reading messages in a dead letter, see Reading Messages in a Dead Letter Queue (using API functions).