Skip to main content
Table of Contents

Interface IOutboxRepository

Namespace
Stratara.Abstractions.Outbox
Assembly
Stratara.Abstractions.dll

Repository over the outbox_entry table — durable queue of messages that couldn't be published directly to the bus and are retried by the outbox worker.

public interface IOutboxRepository
Extension Methods

Methods

AddAsync<T>(Guid, T, CancellationToken)

Persist an outbox entry under an identity the caller chose, so the caller can remove it later by that identity. Used by a dispatcher that stores a bundle with the commit and deletes it once the bus has accepted it.

Task AddAsync<T>(Guid id, T outboxData, CancellationToken cancellationToken)

Parameters

id Guid

The identity of the entry.

outboxData T

The payload.

cancellationToken CancellationToken

Cancels the operation.

Returns

Task

Type Parameters

T

The serialised payload type (command envelope or event bundle).

Exceptions

NotSupportedException

The repository does not support caller-chosen identities.

AddAsync<T>(T, CancellationToken)

Persist an outbox entry for later delivery.

Task AddAsync<T>(T outboxData, CancellationToken cancellationToken)

Parameters

outboxData T
cancellationToken CancellationToken

Returns

Task

Type Parameters

T

The serialised payload type (command envelope or event bundle).

DeleteAsync(Guid, CancellationToken)

Remove an entry once it has been published successfully.

Task DeleteAsync(Guid id, CancellationToken cancellationToken)

Parameters

id Guid
cancellationToken CancellationToken

Returns

Task

DeleteManyAsync(IReadOnlyList<Guid>, CancellationToken)

Removes a set of entries in one call.

Task DeleteManyAsync(IReadOnlyList<Guid> ids, CancellationToken cancellationToken)

Parameters

ids IReadOnlyList<Guid>

The identities of the entries; an identity that matches no entry is ignored.

cancellationToken CancellationToken

Cancels the operation.

Returns

Task

A task that completes when every entry is removed.

Remarks

The default removes the entries one at a time through DeleteAsync(Guid, CancellationToken), so an implementation written before this member keeps working unchanged. An implementation backed by a database overrides it with a single statement.

Exceptions

ArgumentNullException

ids is null.

GetManyAsync<T>(int, CancellationToken)

Return up to batchSizes oldest entries of type T.

Task<IReadOnlyList<OutboxEntry>> GetManyAsync<T>(int batchSizes, CancellationToken cancellationToken)

Parameters

batchSizes int
cancellationToken CancellationToken

Returns

Task<IReadOnlyList<OutboxEntry>>

Type Parameters

T