Class InboxBuilder<TDbContext>
Builder for configuring the inbox pattern.
public class InboxBuilder<TDbContext> where TDbContext : DbContext
Type Parameters
TDbContext
- Inheritance
-
InboxBuilder<TDbContext>
- Inherited Members
Methods
- Configure(Action<InboxOptions>)
Configures all options via an action.
- WithBatchSize(int)
Sets the number of handler statuses 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.
- WithConsumeChannelInboxRequirement(ConsumeChannelInboxRequirement)
Requires consume channels to use inbox according to the selected policy.
- WithHandlerTimeout(TimeSpan)
Sets the maximum time a handler is allowed to run before being cancelled. Timeout cancellation is treated as a handler failure and increments the error count.
- 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 inboxes or conflict with the outbox lock.
- WithMaxRetries(int)
Sets the maximum number of delivery attempts before marking a handler as poisoned. A value of 1 means the handler runs once and 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 pending handler deliveries.
- WithRestartDelay(TimeSpan)
Sets the delay before restarting the inbox processor after a crash.
- WithRetention(TimeSpan)
Enables automatic cleanup of completed handler statuses older than the specified retention period. Poisoned statuses are never auto-deleted — they require manual investigation. Orphaned inbox messages (with no remaining handler statuses) are also deleted.
- WithStuckMessageThreshold(TimeSpan)
Sets how long a handler status can remain in "processing" state before being considered stuck.
- WithoutBackgroundProcessing()
Prevents the InboxProcessor<TDbContext> from being registered as a hosted service. Use this in integration tests where you want deterministic control over when inbox processing runs (e.g. by calling
InboxMessageProcessor.ProcessBatchAsyncdirectly). Note: this also prevents InboxCleanupService<TDbContext> from running, even when WithRetention(TimeSpan) is configured.