Table of Contents

Class OutboxBuilder<TDbContext>

Namespace
Ratatoskr.EfCore
Assembly
Ratatoskr.EfCore.dll

Builder for configuring the outbox pattern.

public class OutboxBuilder<TDbContext> where TDbContext : DbContext

Type Parameters

TDbContext
Inheritance
OutboxBuilder<TDbContext>
Inherited Members

Methods

Configure(Action<OutboxOptions>)

Configures all options via an action.

WithBatchSize(int)

Sets the number of messages to process in each batch.

WithCleanupBatchSize(int)

Sets the maximum number of rows to delete per cleanup batch. Only applies when WithRetention(TimeSpan) is configured.

WithCleanupInterval(TimeSpan)

Sets how often the cleanup service runs. Only applies when WithRetention(TimeSpan) is configured.

WithCleanupLockName(string)

Sets the distributed lock name for the cleanup service. Only one instance acquires the lock per cleanup cycle; others skip the cycle.

WithLockAcquireTimeout(TimeSpan)

Sets the maximum time to wait when acquiring the distributed lock.

WithLockName(string)

Sets the distributed lock name. Change this if you have multiple outboxes or conflict with the inbox lock.

WithMaxMessageSize(int)

Sets the maximum allowed size of the serialized message body in bytes. Messages exceeding this limit will cause SaveChangesAsync to throw.

WithMaxRetries(int)

Sets the maximum number of retry attempts before marking a message as poisoned. A value of 0 means the message is poisoned on the first failure.

WithMaxRetryDelay(TimeSpan)

Sets the maximum backoff delay between retry attempts.

WithPollingInterval(TimeSpan)

Sets the polling interval for checking the database for unsent messages.

WithRestartDelay(TimeSpan)

Sets the delay before restarting the outbox processor after a crash.

WithRetention(TimeSpan)

Enables automatic cleanup of successfully processed messages older than the specified retention period. Poisoned messages are never auto-deleted — they require manual investigation.

WithSendTimeout(TimeSpan)

Sets the maximum time a send operation is allowed to run before being cancelled. Timeout cancellation is treated as a failure and increments the error count.

WithStuckMessageThreshold(TimeSpan)

Sets how long a message can remain in "processing" state before being considered stuck.

WithoutBackgroundProcessing()

Prevents the Ratatoskr.EfCore.Internal.OutboxProcessor<TDbContext> from being registered as a hosted service. Use this in integration tests where you want deterministic control over when outbox processing runs (e.g. by calling OutboxMessageProcessor.ProcessBatchAsync directly). Note: this also prevents Ratatoskr.EfCore.Internal.OutboxCleanupService<TDbContext> from running, even when WithRetention(TimeSpan) is configured.