DVA-C02 Question 394
Single answerYou are developing an application that processes orders from an SQS queue. The application must ensure that the processing of orders is highly concurrent but does not allow duplicate processing of the same message. Which approach should you use to achieve this?
- A
Use an SQS FIFO queue and ensure that the
MessageGroupIdis the same for all messages. - B
Use an SQS Standard queue and implement client-side deduplication logic.
- C
Use an SQS FIFO queue and set a unique
MessageGroupIdfor each order. - D
Use an SQS Standard queue with long polling enabled and process messages in parallel without additional checks.
Show answer and explanation
Correct answer: C
Explanation
To achieve high concurrency while preventing duplicate message processing, you should use an SQS FIFO queue with a unique MessageGroupId for each order. FIFO queues guarantee exactly-once processing and allow parallel processing of messages in different groups. Standard queues, while supporting high concurrency, do not guarantee exactly-once delivery, and client-side deduplication introduces unnecessary complexity and risk.
- A. Incorrect.
This option is incorrect. While FIFO queues ensure message order, using the same
MessageGroupIdfor all messages would serialize message processing, which eliminates concurrency. - B. Incorrect.
This option is incorrect. Although SQS Standard queues allow high concurrency, they do not guarantee exactly-once processing, and implementing client-side deduplication is error-prone and not ideal for this scenario.
- C. Correct.
This option is correct. SQS FIFO queues ensure exactly-once message processing and allow high concurrency when unique
MessageGroupIds are assigned to each order, as messages in different groups can be processed in parallel. - D. Incorrect.
This option is incorrect. While SQS Standard queues and long polling support high concurrency, they do not guarantee that messages will not be processed more than once, which violates the requirement to avoid duplicate processing.