title | summary | reviewed | component | related | |
---|---|---|---|---|---|
Discarding expired messages |
Using native MSMQ features to discard messages not processed within a provided time window. |
2023-06-02 |
MsmqTransport |
|
The MSMQ transport can handle messages with a Time-To-Be-Received (TTBR) set in two ways.
When a message with a TTBR value is sent, NServiceBus translates the value to the native TTBR property of the MSMQ message. MSMQ continuously checks the Time-To-Be-Received of all queued messages. As soon as the message has expired, it is removed from the queue, and disk space gets reclaimed.
Note
MSMQ enforces a single Time-To-Be-Received value for all messages in a transaction. If multiple messages enlist in a single transaction, then the TTBR from the first message will be used for all messages, leading to potentially unintentional message expiration. To prevent message loss, TTBR is not supported for endpoints with transaction mode SendsAtomicWithReceive
or TransactionScope
by default.
partial: ttbr-send
NServiceBus also annotates outgoing messages with an NServiceBus.TimeToBeReceived
header.
partial: ttbr-receive