Event-Driven Architecture for Beginners
Let a completed fact trigger later work
One committed fact, several consumers
An order is saved. Shipping, email and reporting need to react, but the order response may not need to wait for all of them. An event describes something that happened, such as OrderCreated, so interested consumers can process it.
Event-driven architecture connects producers and consumers through such notifications. It can reduce direct waiting and let teams process work independently. It also creates delayed state, retry, ordering and visibility work that must be designed explicitly.
What you’ll learn
- Distinguish a past-tense event from a command requesting work.
- Connect durable writes with event publication and duplicate-safe consumers.
- Choose asynchronous boundaries from user-visible timing and recovery needs.
Define the fact and its useful context
A command asks a recipient to do something, such as CreateOrder. An event states a result, such as OrderCreated. A consumer may use the fact to decide its own next action.
Include an event identifier, the relevant entity identifier, a schema version and the fields consumers actually need. Avoid broadcasting unnecessary personal data. A timestamp alone is not a universal ordering mechanism.
Define who owns the fact and what it means. Does OrderCreated mean committed, paid, or merely accepted for later processing? Different meanings lead to different downstream behaviour.
Choose the commit and duplicate-handling rules
Explore the design choices
Compare the visible consequences. With JavaScript enabled, choose an option in each scenario to assemble your decision record.
This is an exploratory design exercise. It does not run infrastructure, measure capacity or replace the lesson’s quiz.
The order must survive a restart, and downstream work can happen later. Choose how the event relates to the order write and what a consumer does with repeated delivery.
All consequences remain visible. An outbox reduces a specific publication gap; it does not eliminate every duplicate or make all services share one transaction.
Bridge a durable write and later publication
A transactional outbox stores an event record alongside the business change in one database transaction where that guarantee is supported. A relay reads committed entries and publishes them later.
The relay can publish an event and crash before recording publication, then publish it again after restart. Consumers still need duplicate-safe effects. Processing a marker before an effect, or after it without coordination, can create different loss or duplication risks.
Track publication backlog and recovery. A stored event is not useful downstream until the publication and consumer paths make progress.
Delayed and reordered events affect what users see
Consumers may update their displays later than the source commit. Explain this delay to users when relevant, and offer a way to inspect authoritative status.
Ordering is usually scoped to a key, partition or configured product behaviour, not all events everywhere. If an update arrives before creation or an older version arrives after a newer one, the consumer needs an explicit rule.
Schema changes need compatibility planning. Replay needs retention, access controls and a decision about whether old events should repeat external effects. A debugging replay must not accidentally ship an order twice.
Choose the messaging tool from the workflow
Evaluate RabbitMQ for appropriate queue/routing needs, Kafka for retained partitioned event-log use cases, or managed queues and event-routing services when their contracts fit. These are different products, not interchangeable throughput tiers; see the course’s message queue lesson for practical options.
AWS outbox guidance describes the publication gap and duplicate considerations. Source checked 6 October 2026. A broker’s deduplication feature does not automatically make every external business effect exactly once.
For independent notifications, delayed delivery may be acceptable. For immediate authorization or a current inventory decision, an asynchronous copied view may not meet the requirement. Measure backlog age, successful processing and end-to-end completion time.
Distinguish events, streaming and the authoritative record
See the responsibility
An event-driven service reacts to published facts. Event streaming transports or processes an ongoing sequence. Event sourcing stores the ordered events as the authoritative history from which application state is reconstructed. Using a broker does not automatically make the broker’s topic your authoritative business history.
CQRS separates command handling from query models. It can be used with event sourcing, but does not require it. A derived query model may lag; state the visible freshness contract instead of promising immediate consistency everywhere.
Event-sourced designs need stable meaning across schema versions, replay rules, snapshots and privacy/deletion policies. Rebuilding a projection must not resend old payment charges or emails. Separate rebuilding state from executing irreversible external effects. Read sagas for multi-owner business recovery.
Check your design decision
Check your design decision
Check the added design rule
Go deeper into the event patterns
The existing sections explain the boundaries. Continue with Transactional Outbox, Event Sourcing and CQRS for separate examples and decisions. Observer covers a smaller local notification relationship.
Decouple waiting without losing the meaning
Events describe facts and allow later work. Define their contract, ownership and user-visible delay.
Coordinate durable publication intent, handle duplicates and ordering, and monitor progress. Asynchronous boundaries change the service promise rather than removing the need for correctness.
Reaching the recap and completing the quizzes are separate milestones.