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 -minute window. Which SQS FIFO queue configuration and message attributes should the developer use to meet these requirements?
- 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 -minute deduplication window.Answer
- BUse an SQS FIFO queue. Set the queue's visibility timeout to 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.
- CUse 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.
- DUse an SQS FIFO queue. Set the AWS Lambda function consumer's timeout to 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 -minute deduplication window is automatically discarded by SQS.
Step-by-Step Solution
Key Concept
Amazon SQS FIFO queue deduplication and ordering mechanics
Estimated Time:1m 30s