A developer is building a ticket reservation system where booking and payment events must be processed in the exact order they are received per booking, and duplicate events must be ignored. The developer uses an Amazon SNS FIFO topic that fans out to multiple Amazon SQS FIFO queues. Which two parameters or configurations must the developer specify when publishing events to the SNS FIFO topic to ensure message ordering and deduplication? (Select TWO.)
- A unique MessageGroupId for each booking to group messages and ensure they are processed sequentially.Answer
- A MessageDeduplicationId for each event (or enable Content-Based Deduplication on the topic) to prevent duplicate messages from being processed within the deduplication interval.Answer
- CA visibility timeout of 0 seconds on the SQS FIFO queues to allow immediate reprocessing of messages that fail.
- DHardcoded AWS access keys and secret keys inside the SNS client initialization to speed up message publishing throughput.
- EA visibility timeout on the SQS FIFO queue that is exactly equal to the timeout of the downstream consumer Lambda function.
Answer
Configure a unique MessageGroupId for each booking and provide a MessageDeduplicationId (or enable Content-Based Deduplication) when publishing events to the SNS FIFO topic.
To achieve ordering and deduplication in an SNS/SQS FIFO setup, the developer must specify the MessageGroupId (to group messages by a unique identifier like booking ID to guarantee ordering) and MessageDeduplicationId (or enable Content-Based Deduplication to prevent duplicates).
Step-by-Step Solution
Key Concept
Amazon SQS and SNS FIFO queues/topics maintain message ordering using MessageGroupId and guarantee exactly-once processing using MessageDeduplicationId.