Class OutboxDispatcher<TPayload>
- Namespace
- PatternKit.Messaging.Reliability
- Assembly
- PatternKit.Core.dll
Pluggable dispatch loop helper for the Transactional Outbox pattern. Combines an IOutboxStore<TPayload> with an IOutboxDispatcher<TPayload> to provide a reusable relay loop.
public sealed class OutboxDispatcher<TPayload>
Type Parameters
TPayloadThe outbox message payload type.
- Inheritance
-
OutboxDispatcher<TPayload>
- Inherited Members
Constructors
OutboxDispatcher(IOutboxStore<TPayload>, IOutboxDispatcher<TPayload>)
Creates an outbox dispatcher bound to the given store and dispatcher.
public OutboxDispatcher(IOutboxStore<TPayload> store, IOutboxDispatcher<TPayload> dispatcher)
Parameters
storeIOutboxStore<TPayload>dispatcherIOutboxDispatcher<TPayload>
Methods
DrainAsync(CancellationToken)
Drains all pending outbox records by dispatching each through the configured dispatcher. Returns the number of records successfully dispatched.
public ValueTask<int> DrainAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
RunAsync(TimeSpan, CancellationToken)
Continuously drains pending outbox records until cancellationToken is cancelled,
waiting pollInterval between each drain cycle.
public ValueTask RunAsync(TimeSpan pollInterval, CancellationToken cancellationToken = default)
Parameters
pollIntervalTimeSpancancellationTokenCancellationToken