Interface IDeadLetterQueueManager
Manages dead letter queue operations for failed messages.
public interface IDeadLetterQueueManager
- Extension Methods
Remarks
Scope: estate-wide, by construction. Every operation here addresses a broker entity -- a topic, a queue, a subscription -- named by the transport's own options, not a set of rows selected by a predicate. There is no tenant discriminator to apply and none is applied. When several tenants share one transport entity, every operation on this interface observes and modifies all of their messages together.
This is stated rather than left to be inferred, because the persistence-side dead-letter contract nearby says the opposite: a dead-letter store confines every read and every delete to the ambient tenant. A reader who carries that expectation across to this interface will be wrong, and wrong in the destructive direction.
The consequence for a multi-tenant host is a deployment decision, not a call-site one: give each tenant its own dead-letter entity, or accept that dead-letter administration is an operator-level activity that spans the estate. No argument on these methods can narrow it.
Methods
GetDeadLetterMessagesAsync(int, CancellationToken)
Retrieves messages from the dead letter entity, across every tenant sharing it.
Task<IReadOnlyList<DeadLetterMessage>> GetDeadLetterMessagesAsync(int maxMessages, CancellationToken cancellationToken)
Parameters
maxMessagesintMaximum number of messages to retrieve.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<IReadOnlyList<DeadLetterMessage>>
A list of dead letter messages, from every tenant sharing the entity.
Remarks
The returned messages carry their bodies, so on a shared entity this reads one tenant's failed message content into a caller acting for another. It is the widest disclosure on this interface.
GetStatisticsAsync(CancellationToken)
Gets statistics about the dead letter queue.
Task<DeadLetterStatistics> GetStatisticsAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<DeadLetterStatistics>
Dead letter queue statistics.
MoveToDeadLetterAsync(TransportMessage, string, Exception?, CancellationToken)
Moves a message to the dead letter queue.
Task<string> MoveToDeadLetterAsync(TransportMessage message, string reason, Exception? exception, CancellationToken cancellationToken)
Parameters
messageTransportMessageThe message to move to DLQ.
reasonstringThe reason for dead lettering.
exceptionExceptionOptional exception that caused the failure.
cancellationTokenCancellationTokenCancellation token.
Returns
PurgeAllTenantsDeadLetterQueueAsync(CancellationToken)
Purges every message from the dead letter entity, across every tenant sharing it.
Task<int> PurgeAllTenantsDeadLetterQueueAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation token.
Returns
Remarks
Destructive and unbounded: it empties the configured entity. Nothing is selected, so nothing is spared -- a message another tenant has not yet reprocessed is discarded along with the rest, and a dead-lettered message is the only remaining copy. Reprocess what is worth keeping, with ReprocessDeadLetterMessagesAsync(IEnumerable<DeadLetterMessage>, ReprocessOptions, CancellationToken), before calling this.
ReprocessDeadLetterMessagesAsync(IEnumerable<DeadLetterMessage>, ReprocessOptions, CancellationToken)
Reprocesses messages from the dead letter queue.
Task<ReprocessResult> ReprocessDeadLetterMessagesAsync(IEnumerable<DeadLetterMessage> messages, ReprocessOptions options, CancellationToken cancellationToken)
Parameters
messagesIEnumerable<DeadLetterMessage>Messages to reprocess.
optionsReprocessOptionsReprocessing options.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<ReprocessResult>
The result of the reprocessing operation.