Interface IAwsSqsFifoBuilder
Fluent builder interface for configuring AWS SQS FIFO queue settings.
public interface IAwsSqsFifoBuilder
- Extension Methods
Examples
services.AddAwsSqsTransport(sqs =>
{
sqs.ConfigureFifo(fifo =>
{
fifo.ContentBasedDeduplication(true)
.MessageGroupIdSelector<OrderCreated>(msg => msg.TenantId);
});
});
Remarks
This interface follows the Microsoft-style fluent builder pattern.
All methods return this for method chaining.
FIFO queues require either ContentBasedDeduplication(bool) or a DeduplicationIdSelector<T>(Func<T, string>) to be configured. Additionally, a MessageGroupIdSelector<T>(Func<T, string>) is required.
Methods
ContentBasedDeduplication(bool)
Enables or disables content-based deduplication.
IAwsSqsFifoBuilder ContentBasedDeduplication(bool enabled)
Parameters
Returns
- IAwsSqsFifoBuilder
The builder for fluent chaining.
Remarks
When enabled, SQS uses a SHA-256 hash of the message body to generate the deduplication ID. Messages with identical content within the 5-minute deduplication window are treated as duplicates.
DeduplicationIdSelector(Func<object, string>)
Sets a function that generates a deduplication ID from any message object.
IAwsSqsFifoBuilder DeduplicationIdSelector(Func<object, string> selector)
Parameters
selectorFunc<object, string>A function that generates a unique deduplication ID from the message object.
Returns
- IAwsSqsFifoBuilder
The builder for fluent chaining.
Examples
.DeduplicationIdSelector(msg => $"{msg.GetType().Name}-{((dynamic)msg).Id}")
Remarks
Use this overload when you need a single selector that works with multiple message types. For type-safe selectors, use DeduplicationIdSelector<T>(Func<T, string>).
Exceptions
- ArgumentNullException
Thrown when
selectoris null.
DeduplicationIdSelector<T>(Func<T, string>)
Sets a type-safe function that generates a deduplication ID from a message.
IAwsSqsFifoBuilder DeduplicationIdSelector<T>(Func<T, string> selector)
Parameters
Returns
- IAwsSqsFifoBuilder
The builder for fluent chaining.
Type Parameters
TThe message type.
Examples
.DeduplicationIdSelector<OrderCreated>(msg => $"order-{msg.OrderId}")
Remarks
The deduplication ID prevents duplicate message delivery within a 5-minute window. If content-based deduplication is disabled, this selector is required.
Exceptions
- ArgumentNullException
Thrown when
selectoris null.
MessageGroupIdSelector(Func<object, string>)
Sets a function that generates a message group ID from any message object.
IAwsSqsFifoBuilder MessageGroupIdSelector(Func<object, string> selector)
Parameters
Returns
- IAwsSqsFifoBuilder
The builder for fluent chaining.
Examples
// Global ordering (all messages in same group)
.MessageGroupIdSelector(_ => "global")
// Dynamic tenant extraction
.MessageGroupIdSelector(msg => ((ITenantMessage)msg).TenantId)
Remarks
Use this overload when you need a single selector that works with multiple message types. For type-safe selectors, use MessageGroupIdSelector<T>(Func<T, string>).
Exceptions
- ArgumentNullException
Thrown when
selectoris null.
MessageGroupIdSelector<T>(Func<T, string>)
Sets a type-safe function that generates a message group ID from a message.
IAwsSqsFifoBuilder MessageGroupIdSelector<T>(Func<T, string> selector)
Parameters
Returns
- IAwsSqsFifoBuilder
The builder for fluent chaining.
Type Parameters
TThe message type.
Examples
// Order by tenant
.MessageGroupIdSelector<OrderCreated>(msg => msg.TenantId)
// Order by aggregate
.MessageGroupIdSelector<OrderCreated>(msg => msg.OrderId.ToString())
Remarks
The message group ID determines the ordering boundary. Messages with the same group ID are processed in strict FIFO order. Different groups can be processed in parallel while maintaining order within each group.
Exceptions
- ArgumentNullException
Thrown when
selectoris null.