Table of Contents

Class InMemoryOutboxStore<TPayload>

Namespace
PatternKit.Messaging.Reliability
Assembly
PatternKit.Core.dll

Thread-safe in-memory implementation of IOutboxStore<TPayload> for tests, demos, and single-process applications.

public sealed class InMemoryOutboxStore<TPayload> : IOutboxStore<TPayload>

Type Parameters

TPayload

The outbox message payload type.

Inheritance
InMemoryOutboxStore<TPayload>
Implements
IOutboxStore<TPayload>
Inherited Members

Properties

Records

All records currently held in the store.

public IReadOnlyList<OutboxMessage<TPayload>> Records { get; }

Property Value

IReadOnlyList<OutboxMessage<TPayload>>

Methods

EnqueueAsync(Message<TPayload>, string?, DateTimeOffset?, CancellationToken)

Adds a message to the outbox and returns the stored record.

public ValueTask<OutboxMessage<TPayload>> EnqueueAsync(Message<TPayload> message, string? id = null, DateTimeOffset? createdAt = null, CancellationToken cancellationToken = default)

Parameters

message Message<TPayload>
id string
createdAt DateTimeOffset?
cancellationToken CancellationToken

Returns

ValueTask<OutboxMessage<TPayload>>

MarkDispatchedAsync(string, DateTimeOffset, CancellationToken)

Marks a message as successfully dispatched.

public ValueTask MarkDispatchedAsync(string id, DateTimeOffset dispatchedAt, CancellationToken cancellationToken = default)

Parameters

id string
dispatchedAt DateTimeOffset
cancellationToken CancellationToken

Returns

ValueTask

MarkFailedAsync(string, string?, CancellationToken)

Records a failed dispatch attempt for a message.

public ValueTask MarkFailedAsync(string id, string? error, CancellationToken cancellationToken = default)

Parameters

id string
error string
cancellationToken CancellationToken

Returns

ValueTask

SnapshotPendingAsync(CancellationToken)

Returns all messages that have not yet been dispatched.

public ValueTask<IReadOnlyList<OutboxMessage<TPayload>>> SnapshotPendingAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

ValueTask<IReadOnlyList<OutboxMessage<TPayload>>>