Class AwsSqsFifoOptions
Configuration options for AWS SQS FIFO (First-In-First-Out) queue settings.
public sealed class AwsSqsFifoOptions
- Inheritance
-
AwsSqsFifoOptions
- Inherited Members
- Extension Methods
Remarks
FIFO queues provide exactly-once processing and strict message ordering. Use FIFO queues when the order of operations and events is critical.
Key FIFO constraints:
- Queue names must end with
.fifosuffix MessageGroupIdis required for all messages- Either ContentBasedDeduplication or a
DeduplicationIdis required
Fields
FifoQueueSuffix
The required suffix for FIFO queue names.
public const string FifoQueueSuffix = ".fifo"
Field Value
Properties
ContentBasedDeduplication
Gets or sets a value indicating whether content-based deduplication is enabled.
public bool ContentBasedDeduplication { get; set; }
Property Value
Remarks
When enabled, SQS uses a SHA-256 hash of the message body to generate the
MessageDeduplicationId. This means two messages with identical content
(sent within the 5-minute deduplication interval) are treated as duplicates.
If ContentBasedDeduplication is disabled, you must provide a DeduplicationIdSelector to generate unique deduplication IDs.
DeduplicationIdSelector
Gets or sets the function that generates a deduplication ID from a message.
public Func<object, string>? DeduplicationIdSelector { get; set; }
Property Value
- Func<object, string>
A function that takes a message object and returns a unique deduplication ID string, or null if using content-based deduplication.
Examples
options.DeduplicationIdSelector = msg => $"{msg.GetType().Name}_{((IMessage)msg).Id}";
Remarks
The deduplication ID is used by SQS to identify duplicate messages within a 5-minute deduplication interval. Messages with the same deduplication ID received within this window are considered duplicates.
If ContentBasedDeduplication is enabled, this selector is optional but can be used to override the default content-based deduplication.
HasMessageGroupIdSelector
Gets a value indicating whether a message group ID selector is configured.
public bool HasMessageGroupIdSelector { get; }
Property Value
- bool
true if a MessageGroupIdSelector is configured; otherwise, false.
Remarks
A message group ID selector is required for FIFO queues.
HasValidDeduplication
Gets a value indicating whether deduplication configuration is valid.
public bool HasValidDeduplication { get; }
Property Value
- bool
true if either ContentBasedDeduplication is enabled or a DeduplicationIdSelector is configured; otherwise, false.
Remarks
FIFO queues require one of these deduplication methods to be configured.
MessageGroupIdSelector
Gets or sets the function that generates a message group ID from a message.
public Func<object, string>? MessageGroupIdSelector { get; set; }
Property Value
- Func<object, string>
A function that takes a message object and returns a message group ID string. This is required for FIFO queues.
Examples
// Group by tenant for tenant-isolated ordering
options.MessageGroupIdSelector = msg => ((ITenantMessage)msg).TenantId;
// Global ordering (all messages in same group)
options.MessageGroupIdSelector = _ => "global";
Remarks
Messages with the same message group ID are processed in strict order (FIFO). Messages with different group IDs can be processed in parallel while maintaining order within each group.
Common patterns include:
- Use tenant ID for multi-tenant applications
- Use aggregate/entity ID for event sourcing
- Use a constant value for global ordering
Methods
EnsureFifoSuffix(string)
Ensures a queue name ends with the .fifo suffix.
public static string EnsureFifoSuffix(string queueName)
Parameters
queueNamestringThe queue name to normalize.
Returns
- string
The queue name with the
.fifosuffix appended if not already present.
Exceptions
- ArgumentException
Thrown when
queueNameis null, empty, or whitespace.
IsValidFifoQueueUrl(string)
Validates the FIFO queue URL ends with the required .fifo suffix.
public static bool IsValidFifoQueueUrl(string queueUrl)
Parameters
queueUrlstringThe queue URL to validate.