Question

Difficulty: MediumMessage-Based Integration using Amazon SQS and SNS

A developer is designing a backend for a retail checkout system. Order placement events must be processed in the exact sequence they are submitted for each customer. Additionally, the system must filter out duplicate checkout submissions if a customer accidentally clicks the "Submit Order" button multiple times within a 55-minute window. Which SQS FIFO queue configuration and message attributes should the developer use to meet these requirements?

  1. Use an SQS FIFO queue. Set the MessageGroupId to the customer ID to ensure sequential processing per customer, and set the MessageDeduplicationId to a unique transaction ID to prevent duplicate order processing within the 55-minute deduplication window.Answer
  2. B
    Use an SQS FIFO queue. Set the queue's visibility timeout to 55 minutes to prevent duplicate processing of retried orders, and use the customer ID as the MessageGroupId while letting SQS auto-generate the deduplication ID based on the order timestamp.
  3. C
    Use an SQS standard queue. Hardcode the AWS credentials in the SDK client setup to ensure low-latency API access, and configure an AWS Lambda consumer to manually deduplicate orders using in-memory global variables.
  4. D
    Use an SQS FIFO queue. Set the AWS Lambda function consumer's timeout to 1515 minutes, and rely on the Lambda function's execution context reuse to track processed order IDs in a global array to handle deduplication.

Answer

Use an SQS FIFO queue, setting the MessageGroupId to the customer ID to maintain ordering per customer, and setting the MessageDeduplicationId to a unique transaction ID to prevent duplicates within the 5-minute window.
Amazon SQS FIFO queues ensure that messages are processed exactly once and in the order they are sent. By setting the MessageGroupId to the customer ID, ordering is guaranteed specifically for each customer, allowing concurrent processing for different customers. Setting the MessageDeduplicationId to a unique transaction ID ensures that any retry containing the same ID within the 55-minute deduplication window is automatically discarded by SQS.

Step-by-Step Solution

1
Determine the required queue type to handle ordering and deduplication.
Amazon SQS FIFO queue is selected.
Standard queues do not guarantee message ordering or deduplication, whereas FIFO queues guarantee first-in-first-out delivery and exactly-once processing.
2
Configure the grouping strategy to ensure messages are ordered per customer.
Set the MessageGroupId message attribute to the customer ID.
SQS FIFO queues group messages by MessageGroupId. Messages within the same group are processed in strict sequential order, allowing parallel processing across different groups.
3
Configure the deduplication strategy to filter out retries within a 55-minute window.
Set the MessageDeduplicationId message attribute to a unique transaction ID.
Amazon SQS FIFO queues use the MessageDeduplicationId to identify and discard duplicate messages sent within a 55-minute deduplication window.

Key Concept

Amazon SQS FIFO queue deduplication and ordering mechanics
Estimated Time:1m 30s
Rate this question