Design: Idempotent Event Consumer System
Design focuses on the event consumer microservice and its idempotency mechanisms. Event producers, event brokers, and downstream systems are out of scope.
Functional Requirements
Non-Functional Requirements
Jump into concepts and practice - no test required
+----------------+ +------------------+ +--------------------+
| Event Producer | ----> | Event Broker | ----> | Event Consumer |
+----------------+ +------------------+ +--------------------+
| |
| v
| +-------------+
| | Idempotency |
| | Store |
| +-------------+
|
v
+--------------------+
| Downstream Systems |
+--------------------+idempotent event consumer in microservices?processed_events = set()
def consume(event):
if event.id in processed_events:
return "Skipped"
process(event)
processed_events.add(event.id)
return "Processed"
What will be the output if the same event with id=42 is consumed twice?