A payment worker reads orders from an Amazon SQS standard queue and charges each customer through a third-party API. A few customers are charged twice. Logs show the same message processed twice: sometimes after a slow payment call exceeded the visibility timeout, and occasionally when processing was fast. Which change prevents duplicate charges in both cases?
Choose one.
At-least-once delivery means consumers that cause side effects must be idempotent.
There are two causes of duplicates. A visibility timeout shorter than processing makes the message reappear, and SQS standard queues deliver at least once, so a message can occasionally arrive twice anyway. Only an idempotency check on a business key covers both causes. A longer visibility timeout fixes only the first cause. FIFO deduplication works on sends, not on redelivery after a timeout. Deleting first trades duplicates for lost orders.
- List each cause of duplicates the logs reveal.
- Recall that standard queues guarantee at-least-once, not exactly-once, delivery.
- Check whether each option removes both causes or only one.
- Prefer a check on a business key (the order ID) before the side effect.
Exam tip: With at-least-once delivery, make the side effect idempotent; queue settings alone cannot prevent every duplicate.
DVA-C03 Application Development: Decoupling, APIs, SDKs, Events, Streams and AI — the lesson that teaches this.