System Design · Senior · Question 6 of 75
Why must consumers of an "at-least-once" queue be idempotent?
- ✓Correct answer: A message may arrive again, and that must cause no harm
- 2Otherwise the queue deletes the message before it is processed
- 3Idempotency is only needed for queues with a single consumer
Explanation
Exactly-once is expensive or unattainable in practice, so systems guarantee "at least once". The handler stores ids of processed messages or makes operations idempotent (upsert instead of insert).