Class PoisonMessageHandler
- Namespace
- Excalibur.Dispatch.ErrorHandling
- Assembly
- Excalibur.Dispatch.dll
Default implementation of the poison message handler.
public sealed class PoisonMessageHandler : IPoisonMessageHandler, IDisposable
- Inheritance
-
PoisonMessageHandler
- Implements
- Inherited Members
- Extension Methods
Constructors
PoisonMessageHandler(IDeadLetterStore, DispatchJsonSerializer, IServiceProvider, IOptions<PoisonMessageOptions>, ILogger<PoisonMessageHandler>)
Initializes a new instance of the PoisonMessageHandler class.
public PoisonMessageHandler(IDeadLetterStore deadLetterStore, DispatchJsonSerializer serializer, IServiceProvider serviceProvider, IOptions<PoisonMessageOptions> options, ILogger<PoisonMessageHandler> logger)
Parameters
deadLetterStoreIDeadLetterStoreserializerDispatchJsonSerializerserviceProviderIServiceProvideroptionsIOptions<PoisonMessageOptions>loggerILogger<PoisonMessageHandler>
Methods
Dispose()
Disposes the handler and releases the activity source.
public void Dispose()
GetStatisticsAsync(CancellationToken)
Gets statistics about poison messages.
public Task<PoisonMessageStatistics> GetStatisticsAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<PoisonMessageStatistics>
A task containing poison message statistics.
HandlePoisonMessageAsync(IDispatchMessage, IMessageContext, string, CancellationToken, Exception?)
Handles a poison message by moving it to the dead letter queue.
[RequiresUnreferencedCode("Poison message handling serializes message payloads and metadata which may require preserved members.")]
[RequiresDynamicCode("Uses dynamic code generation which requires JIT compilation")]
public Task HandlePoisonMessageAsync(IDispatchMessage message, IMessageContext context, string reason, CancellationToken cancellationToken, Exception? exception = null)
Parameters
messageIDispatchMessageThe poison message to handle.
contextIMessageContextThe message context containing metadata.
reasonstringThe reason why the message is considered poison.
cancellationTokenCancellationTokenThe cancellation token.
exceptionExceptionThe exception that caused the message to be considered poison, if any.
Returns
- Task
A task representing the asynchronous operation.
ReplayMessageAsync(string, CancellationToken)
Attempts to replay a message from the dead letter queue.
[RequiresUnreferencedCode("Dead letter message replay uses reflection to resolve message types from AssemblyQualifiedName strings for dynamic deserialization.")]
[RequiresDynamicCode("Uses dynamic code generation which requires JIT compilation")]
public Task<bool> ReplayMessageAsync(string messageId, CancellationToken cancellationToken)
Parameters
messageIdstringThe ID of the message to replay.
cancellationTokenCancellationTokenThe cancellation token.