Using FIFO with the Amazon Message Processing Framework for .NET - Amazon SDK for .NET
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Using FIFO with the Amazon Message Processing Framework for .NET

This is prerelease documentation for a feature in preview release. It is subject to change.

For use cases where message ordering and message deduplication are critical, the Amazon Message Processing Framework for .NET supports first-in-first-out (FIFO) Amazon SQS queues and Amazon SNS topics.

Publishing

When publishing messages to a FIFO queue or topic, you must set the message group ID, which specifies the group that the message belongs to. Messages within a group are processed in order. You can set this on the SQS-specific and SNS-specific message publishers.

await _sqsPublisher.PublishAsync(message, new SQSOptions { MessageDeduplicationId = <message-deduplication-id>, MessageGroupId = <message-group-id> });

Subscribing

When handling messages from a FIFO queue, the framework handles messages within a given message group in the order in which they were received for each ReceiveMessages call. The framework enters this mode of operation automatically when configured with a queue ending in .fifo.

await Host.CreateDefaultBuilder(args) .ConfigureServices(services => { // Register the AWS Message Processing Framework for .NET. services.AddAWSMessageBus(builder => { // Because this is a FIFO queue, the framework automatically handles these messages in order. builder.AddSQSPoller("https://sqs.us-west-2.amazonaws.com/012345678910/MPF.fifo"); builder.AddMessageHandler<OrderMessageHandler, OrderMessage>(); }); }) .Build() .RunAsync();