Dead-letter queues are system-generated queues used for storing messages that could not be delivered. Message Queuing creates a transactional and a nontransactional dead-letter queue on each computer during setup. Storing undelivered messages on the source computer is called negative source journaling.
When a message is placed in a dead-letter queue, Message Queuing changes the class property of the message (PROPID_M_CLASS or MSMQMessage.MsgClass) to reflect the last known status of the message. For example, Message Queuing will change the class of the message and place it in the appropriate dead-letter queue if the message's time-to-reach-queue timer or time-to-be-received timer expires.
Only Message Queuing places messages in dead-letter queues. Applications can only read and delete messages in dead-letter queues.
Nontransactional Messages and Dead-Letter Queues
When the journaling level (PROPID_M_JOURNAL or MSMQMessage.Journal) of a nontransactional message is set to MQMSG_DEADLETTER, any Message Queuing computer that cannot deliver the message before its time-to-reach-queue timer expires will place the undelivered message in the nontransactional dead-letter queue of that computer. This can be the source computer, the target computer, or any Message Queuing routing server in between. When an undelivered message is placed in a dead-letter queue, Message Queuing sets the class property of the message to indicate the reason why the message was not delivered.
|Only one copy of a message is stored on a computer at one time. When a message reaches a computer successfully, it is stored in an internal queue on that computer. If the message cannot be delivered to the next computer, it is then stored in the current computer's dead-letter queue.|
Transactional Messages and Dead-Letter Queues
When the journaling level (PROPID_M_JOURNAL or MSMQMessage.Journal) of a transactional message is set to MQMSG_DEADLETTER, the source queue manager places a copy of the message in the local transactional dead-letter queue if the source queue manager receives a negative acknowledgment message or does not receive a confirmation from the target queue manager indicating that the message was successfully retrieved from the destination queue (for example, if the message's time-to-be-received timer elapses before the source queue manager receives an acknowledgment message indicating that the message reached the destination queue or was retrieved from it). No notification is returned within the transaction confirmation process if the message is not delivered, is not received, or the receiving transaction is aborted. By default, the journaling property of transactional messages is not set to MQMSG_DEADLETTER.
Thus, the presence of a message in the transactional dead-letter queue confirms that it was not retrieved from the destination queue within a fixed time interval, and the message's class indicates the reason why the message was not retrieved.
Referencing Dead-Letter Queues
The nontransactional and transactional dead-letter queues can be referenced by a machine format name or a direct format name. The following lines show the syntax of these format names:
MACHINE=ComputerGUID;DEADLETTER MACHINE=ComputerGUID;DEADXACT DIRECT=AddressSpecification\SYSTEM$;DEADLETTER (Introduced in MSMQ 2.0) DIRECT=AddressSpecification\SYSTEM$;DEADXACT (Introduced in MSMQ 2.0)
The following lines of code are examples of nontransactional and transactional dead-letter queue format name strings (note that the format name strings are null-terminated Unicode strings).
LPWSTR wsz = L"MACHINE=308FB580-1EB2-11CA-923B-08002B1075A7;DEADLETTER"; LPWSTR wsz = L"MACHINE=308FB580-1EB2-11CA-923B-08002B1075A7;DEADXACT"; LPWSTR wsz = L"DIRECT=OS:Mike01\SYSTEM$;DEADLETTER"; LPWSTR wsz = L"DIRECT=OS:Mike01\SYSTEM$;DEADXACT";
MSMQ 1.0 Restrictions on Source Journaling
MSMQ 1.0 did not allow sending applications to specify source journaling. For MSMQ 1.0, all transactional messages are placed in the transactional dead-letter queue after the time-to-be-received timer expires. All later versions of Message Queuing now allow complete control over source journaling.
|For information on||See|
When to use dead-letter queues
Code examples for requesting negative source journaling
Other system queues
Positive and negative acknowledgment messages
The elements and syntax of machine format names
The elements and syntax of direct format names