Question

Difficulty: MediumMessage-Based Integration using Amazon SQS and SNS

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.)

  1. A unique MessageGroupId for each booking to group messages and ensure they are processed sequentially.Answer
  2. 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
  3. C
    A visibility timeout of 0 seconds on the SQS FIFO queues to allow immediate reprocessing of messages that fail.
  4. D
    Hardcoded AWS access keys and secret keys inside the SNS client initialization to speed up message publishing throughput.
  5. E
    A 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

1
Identify the ordering requirements.
Since booking and payment events must be processed in the exact order they are received per booking, a grouping identifier is needed. Grouping messages by booking ID using MessageGroupId ensures strict ordering within each booking.
SQS and SNS FIFO require MessageGroupId to determine which group of messages must be processed sequentially.
2
Identify the deduplication requirements.
To ignore duplicate events, a deduplication mechanism is required. Providing a MessageDeduplicationId or enabling Content-Based Deduplication ensures that identical messages published within the 5-minute deduplication window are treated as duplicates and discarded.
MessageDeduplicationId is the parameter used by AWS FIFO features to identify and eliminate duplicate messages.

Key Concept

Amazon SQS and SNS FIFO queues/topics maintain message ordering using MessageGroupId and guarantee exactly-once processing using MessageDeduplicationId.
Rate this question