Idempotent Consumers
One-Liner
Consumers that can safely process the same message multiple times.
What It Is
A design approach where message handlers tolerate duplicate delivery without incorrect behavior.
Why It Exists
At-least-once delivery is common; duplicates are inevitable.
How It Works
- Deduplication keys
- Idempotent writes
- State-based guards
Tradeoffs
Pros
- Increased reliability
- Simplified retry logic
Cons
- Additional state or storage
- More complex handlers
Failure Modes
- Partial side effects
- Incorrect deduplication windows
Interview Traps
- Assuming exactly-once delivery
- Confusing idempotency with deduplication
Real-World Usage
Payment processing, event-driven systems, background jobs.
Anti-Patterns
- Relying on broker guarantees alone
Related Concepts
- Message retries
- Transactions