Interface IOutboxProcessingBuilder
Fluent builder interface for configuring outbox processing settings.
public interface IOutboxProcessingBuilder
Examples
outbox.WithProcessing(processing =>
{
processing.BatchSize(100)
.PollingInterval(TimeSpan.FromSeconds(5))
.MaxRetryCount(5)
.RetryDelay(TimeSpan.FromMinutes(1));
});
Remarks
This builder configures how messages are retrieved and processed from the outbox store.
All methods return this for method chaining.
Methods
BatchSize(int)
Sets the maximum number of messages to process in a single batch.
IOutboxProcessingBuilder BatchSize(int size)
Parameters
sizeintThe batch size. Must be greater than 0.
Returns
- IOutboxProcessingBuilder
The builder for fluent chaining.
Remarks
Larger batch sizes can improve throughput but may increase memory usage and processing time per batch. Default is 100.
Exceptions
- ArgumentOutOfRangeException
Thrown when
sizeis less than or equal to 0.
EnableParallelProcessing(int)
Enables parallel processing of messages within a batch.
IOutboxProcessingBuilder EnableParallelProcessing(int maxDegreeOfParallelism = 4)
Parameters
maxDegreeOfParallelismintThe maximum number of concurrent message processing operations. Default is 4.
Returns
- IOutboxProcessingBuilder
The builder for fluent chaining.
Remarks
Parallel processing can improve throughput but may affect message ordering. Only enable if message order is not critical or if you have partitioning in place.
Exceptions
- ArgumentOutOfRangeException
Thrown when
maxDegreeOfParallelismis less than 1.
MaxRetryCount(int)
Sets the maximum number of retry attempts for failed messages.
IOutboxProcessingBuilder MaxRetryCount(int count)
Parameters
countintThe maximum retry count. Must be greater than or equal to 0.
Returns
- IOutboxProcessingBuilder
The builder for fluent chaining.
Remarks
After the maximum retries are exhausted, messages are moved to the dead letter queue if one is configured. Default is 3.
Exceptions
- ArgumentOutOfRangeException
Thrown when
countis negative.
PollingInterval(TimeSpan)
Sets the interval between processing cycles.
IOutboxProcessingBuilder PollingInterval(TimeSpan interval)
Parameters
intervalTimeSpanThe polling interval. Must be positive.
Returns
- IOutboxProcessingBuilder
The builder for fluent chaining.
Remarks
Shorter intervals reduce latency but increase database load. Default is 5 seconds.
Exceptions
- ArgumentOutOfRangeException
Thrown when
intervalis not positive.
ProcessorId(string)
Sets the unique identifier for this processor instance.
IOutboxProcessingBuilder ProcessorId(string processorId)
Parameters
processorIdstringThe processor identifier.
Returns
- IOutboxProcessingBuilder
The builder for fluent chaining.
Remarks
The processor ID is used to identify which instance processed a message, useful for debugging in distributed deployments. If not set, a GUID is generated.
Exceptions
- ArgumentException
Thrown when
processorIdis null, empty, or whitespace.
RetryDelay(TimeSpan)
Sets the delay between retry attempts.
IOutboxProcessingBuilder RetryDelay(TimeSpan delay)
Parameters
delayTimeSpanThe retry delay. Must be positive.
Returns
- IOutboxProcessingBuilder
The builder for fluent chaining.
Remarks
Consider using exponential backoff for transient failures. Default is 5 minutes.
Exceptions
- ArgumentOutOfRangeException
Thrown when
delayis not positive.