Event-Driven Architecture Tutorial with Examples.
Event-driven architecture tutorial: event sourcing, CQRS, message brokers, choreography vs orchestration and the outbox pattern.
Beginner
Start here — no prior experience needed
Events vs Requests: Why the Order Service Doesn't Wait for Email
A synchronous order flow fails outright when email is down; an event-driven one records the order and lets each handler fail independently.
Events vs Commands: Naming Facts You Can't Reject
A command can be refused before anything happens; an event is a fact about something that already did. Naming them wrong hides which is which.
Event Sourcing: Storing What Happened Instead of What's True Now
A mutable balance field loses its own history the moment you overwrite it. An append-only event log rebuilds the same number by replaying every step.
Intermediate
For developers with core concepts down
Event Sourcing: Snapshots So Replay Doesn't Get Slower Forever
Replaying 200,000 events gets measurably slower as a log grows; a snapshot resumes from a known balance and replays only what changed since.
CQRS: Separate Write and Read Models, and the Lag Between Them
A denormalized read model only reflects the write log once a projector actually processes new events — real output showing that lag, and closing it.
The Dual-Write Problem: A DB Commit and a Publish Can Fail Independently
Committing an order and publishing its event are two separate calls that can fail independently, and the gap between them can silently drop data.
Transactional Outbox: Committing the Event With the Data
Writing the event to the same database transaction as the data closes the dual-write gap; a relay then publishes it, at least once.
Idempotent Consumers: Surviving a Duplicate Delivery
The outbox pattern can deliver the same event twice; a consumer that tracks processed event IDs stays correct even when it does.
Dead-Letter Queues: What Happens When Retries Keep Failing
A consumer retrying a poison message forever wastes work on something that will never succeed — route it to a dead-letter queue, then replay once fixed.
Advanced
Production-grade patterns for experienced engineers
Also part of Event-Driven Architecture
Taught in other topics. Each link opens the lesson in its home topic.
Saga Pattern: Orchestrating a Multi-Step Transaction
No single database transaction spans order, payment, and inventory services — a saga orchestrator runs each step in order and tracks what's completed.
Saga Pattern: Real Compensation When a Step Fails
The same orchestrator, now with a deliberate mid-sequence failure — real output showing exactly which completed steps get rolled back, and in what order.
At-Most-Once, At-Least-Once, and Exactly-Once
Reproduce message loss and duplication on purpose, then configure the producer and consumer to get each of Kafka's three delivery guarantees.
Serialization and the Schema Registry
Break a consumer by changing a JSON field, then fix it properly with Avro and a Schema Registry that rejects incompatible changes before they ship.
Pub/Sub: Channels, Patterns, and the Message That Never Arrives
Publishing to a channel with no subscribers doesn't queue the message for later — it's just gone. Real fan-out to multiple subscribers, pattern subscriptions, and sharded Pub/Sub follow.
Incremental Loads and Change Data Capture
Four ways to extract only what changed, why deletes are the hard part, and building SCD type 2 history from a CDC stream that arrives out of order.