Bird
0
0

In a microservice consuming events from a message queue, what happens if the consumer is not idempotent and the same event is delivered twice due to a retry?

medium📝 Analysis Q5 of 15
Microservices - Event-Driven Architecture
In a microservice consuming events from a message queue, what happens if the consumer is not idempotent and the same event is delivered twice due to a retry?
AThe consumer crashes due to duplicate event IDs
BThe event is processed twice, possibly causing duplicate side effects
CThe second event is automatically ignored by the message queue
DThe event is merged with the first event automatically
Step-by-Step Solution
Solution:
  1. Step 1: Understand non-idempotent consumer behavior

    Without idempotency, the consumer processes every event as new, even duplicates.
  2. Step 2: Identify consequences of duplicate processing

    This can cause duplicate database writes, inconsistent state, or repeated side effects.
  3. Final Answer:

    The event is processed twice, possibly causing duplicate side effects -> Option B
  4. Quick Check:

    Non-idempotent = Duplicate side effects [OK]
Quick Trick: No idempotency means duplicates cause repeated effects [OK]
Common Mistakes:
MISTAKES
  • Assuming message queue filters duplicates
  • Thinking consumer crashes on duplicates
  • Believing events merge automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes