Table of Contents

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

deadLetterStore IDeadLetterStore
serializer DispatchJsonSerializer
serviceProvider IServiceProvider
options IOptions<PoisonMessageOptions>
logger ILogger<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

cancellationToken CancellationToken

The 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

message IDispatchMessage

The poison message to handle.

context IMessageContext

The message context containing metadata.

reason string

The reason why the message is considered poison.

cancellationToken CancellationToken

The cancellation token.

exception Exception

The 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

messageId string

The ID of the message to replay.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<bool>

A task representing the asynchronous operation with a boolean indicating success.