Table of Contents

Interface IOutboxWriter

Namespace
Excalibur.Dispatch.Outbox
Assembly
Excalibur.Dispatch.Abstractions.dll

Stages outbound messages for reliable delivery via the outbox pattern.

public interface IOutboxWriter
Extension Methods

Remarks

Inject this interface into handlers to stage outbound messages. The consistency guarantee (eventually-consistent vs. transactional) is determined by configuration, not by which API you call.

Eventually-consistent mode: Messages are buffered during handler execution and staged in the outbox after the handler and its transaction complete. If the process crashes between transaction commit and outbox staging, messages may be lost.

Transactional mode: Messages are written to the outbox store within the ambient transaction, guaranteeing atomicity with the business state change.

Methods

WriteAsync(IDispatchMessage, string?, CancellationToken)

Writes a message to the outbox for reliable delivery.

[RequiresUnreferencedCode("Outbox stores serialize the message payload reflectively; supply JsonSerializerOptions with a source-generated resolver for trimming and AOT.")]
[RequiresDynamicCode("Outbox stores serialize the message payload reflectively; supply JsonSerializerOptions with a source-generated resolver for trimming and AOT.")]
ValueTask WriteAsync(IDispatchMessage message, string? destination, CancellationToken cancellationToken)

Parameters

message IDispatchMessage

The message to stage.

destination string

Optional destination/topic for the message.

cancellationToken CancellationToken

Token to monitor for cancellation.

Returns

ValueTask

A task representing the write operation.

Exceptions

ArgumentNullException

Thrown when message is null.

InvalidOperationException

Thrown in transactional mode when no ambient transaction is available.