SAP-C02 Question 282
Single answerA company is building a serverless application to process and analyze customer feedback data in near real-time. The solution needs to handle large, variable bursts of incoming data, ensure messages are delivered in order, and process each message exactly once. The architecture uses Amazon Simple Queue Service (Amazon SQS) to queue the incoming data, AWS Lambda to process the messages, and Amazon DynamoDB to store the processed results. However, the team notices that the current setup sometimes processes messages out of order. What should the team do to ensure that messages are processed in order and exactly once?
- A
Switch the SQS queue type to a FIFO queue and configure deduplication.
- B
Use AWS Step Functions to orchestrate the message processing workflow.
- C
Enable long polling on the SQS queue to reduce duplicate messages.
- D
Implement an Amazon SNS topic to fan-out messages to multiple SQS queues.
Show answer and explanation
Correct answer: A
Explanation
To ensure messages are processed in order and exactly once, the correct solution is to use an Amazon SQS FIFO queue with deduplication enabled. FIFO queues are designed to guarantee that messages are delivered in the order they are sent and avoid duplicates by using message deduplication IDs. None of the other options fully address both the ordering and deduplication requirements.
- A. Correct.
Switching the SQS queue type to FIFO ensures that messages are processed in the exact order they are sent. Additionally, enabling deduplication ensures that each message is processed only once, fulfilling the requirements of the scenario.
- B. Incorrect.
AWS Step Functions are useful for orchestrating workflows, but they do not inherently guarantee message ordering or prevent duplicate processing in this specific use case.
- C. Incorrect.
Long polling reduces the number of empty responses from the SQS queue but does not guarantee message order or prevent duplicate processing.
- D. Incorrect.
Using an Amazon SNS topic for fan-out increases the complexity of message handling and does not ensure message ordering or deduplication.