13 / 25 · Asynchronous work
Event-driven architecture
In event-driven architecture, components announce facts that happened and other components react. An event such as BookingConfirmed differs from a command such as ConfirmBooking, which asks an owner to perform an action.
What you will practise
- Separate facts from requests
- trace independent consumers
- define replay policy
Before you start: Event identity, command and eventual consistency.
About 4 minutes · offline-generated English female narration · captions included. Diagrams are conceptual; timings are illustrative.
Download MP4CaptionsListen without the video
Download audioChapters and full transcript
Let us understand event-driven architecture. A school posts that sports day has been confirmed. Teachers arrange transport, the canteen plans food and students bring equipment. The announcement is one fact with several independent reactions. If the date is corrected, people need a clear update rather than silently rewriting an announcement they already acted on. In event-driven architecture, components announce facts that happened and other components react. An event such as BookingConfirmed differs from a command such as ConfirmBooking, which asks an owner to perform an action.
Follow the normal path. The booking owner establishes that the booking is confirmed, then reliably publishes the associated fact. Publication and storage must have an explicit failure strategy. The event channel makes the fact available to separate subscribers. Each subscriber has a distinct business responsibility and its own processing state. SeatSpot booking confirmation can trigger receipts, analytics and loyalty updates without the booking service synchronously calling every consumer. This reduces direct coupling but introduces asynchronous coordination.
Now change one condition. Analytics becomes slow while receipt processing continues. Subscriber delay is observable; it should not silently redefine the original booking outcome. A common misunderstanding is this: Publishing an event creates one atomic transaction across subscribers. Independent consumers have separate state, delay and failure boundaries. Think about this. BookingConfirmed is replayed. Should every subscriber repeat its old external action? Pause the video and make your prediction. No. Rebuilding analytics and resending old receipts have different consequences. Each consumer needs an explicit replay policy.
Let us reason with a concrete example. BookingConfirmed has receipt, analytics and loyalty subscribers. A failed analytics consumer should not roll back a valid booking. Loyalty may remain eventually consistent, while seat ownership must stay authoritative. Document each subscriber obligation and recovery/replay rules. Replaying an analytics event is different from sending every historical receipt again. These figures are teaching examples, not production guarantees.
Turn the idea into a design decision. A repeated delivery uses the same logical event identity. Consumers must avoid awarding points or producing another external effect accidentally. Add compatible fields carefully and test old consumers. Retained events and delayed subscribers may outlive the latest deployment. When you try the practice task, look for this result. A repeated event must not award loyalty points twice; replay is a business decision.
Check your understanding. Replay analytics when appropriate, but do not resend historical receipts automatically. Reprocessing policy depends on the side effects owned by each subscriber. Here is a challenge. A loyalty consumer receives BookingConfirmed twice. What must remain true? Pause before the answer. The booking should earn the intended points once. Deduplicate or make the update idempotent within a durable transaction; account for partial failure around external effects. For an interview, discuss versioned contracts, lag and idempotent consumers. Say what you would measure, not only which tool you would buy.
Start with an everyday picture
A school posts that sports day has been confirmed. Teachers arrange transport, the canteen plans food and students bring equipment. The announcement is one fact with several independent reactions. If the date is corrected, people need a clear update rather than silently rewriting an announcement they already acted on.
Why SeatSpot needs this
SeatSpot booking confirmation can trigger receipts, analytics and loyalty updates without the booking service synchronously calling every consumer. This reduces direct coupling but introduces asynchronous coordination.
Trace one step at a time
Move through the diagram at your pace. Teal paths are active; unavailable components are labelled.
Commit a business fact
The booking owner establishes that the booking is confirmed, then reliably publishes the associated fact. Publication and storage must have an explicit failure strategy.
Read all six mechanism steps
Commit a business fact
The booking owner establishes that the booking is confirmed, then reliably publishes the associated fact. Publication and storage must have an explicit failure strategy.
Fan out independently
The event channel makes the fact available to separate subscribers. Each subscriber has a distinct business responsibility and its own processing state.
One subscriber lags
Analytics becomes slow while receipt processing continues. Subscriber delay is observable; it should not silently redefine the original booking outcome.
Deliver the event twice
A repeated delivery uses the same logical event identity. Consumers must avoid awarding points or producing another external effect accidentally.
Evolve the contract
Add compatible fields carefully and test old consumers. Retained events and delayed subscribers may outlive the latest deployment.
Plan recovery and replay
Replay analytics when appropriate, but do not resend historical receipts automatically. Reprocessing policy depends on the side effects owned by each subscriber.
Pause and make a prediction
BookingConfirmed is replayed. Should every subscriber repeat its old external action?
Correct a common misunderstanding
Claim to question: Publishing an event creates one atomic transaction across subscribers.
Better explanation: Independent consumers have separate state, delay and failure boundaries.
Classify messages and replay effects
- Classify ConfirmBooking as a command and BookingConfirmed as a fact.
- Draw receipt, analytics and loyalty subscribers.
- Choose which effects can be replayed and how duplicates are handled.
Check what you can explain
This is your self-check, not an automated grade. Try again without the diagram tomorrow.
0 of 3 goals checked. Choose one remaining idea to practise next.
Teach it back
Without looking, explain what this component changes, what it does not solve and what happens if it fails. Use the animation to check your explanation, then switch to Engineering.
Engineering model and trade-offs
Publish event identity, type, version, time and the minimum useful payload. Choose commands versus facts deliberately. Avoid unnecessary personal data because events can be retained or copied to many consumers.
Assume duplicates, late arrivals and ordering limits unless the actual system guarantees otherwise. Consumers must be idempotent, handle compatible schema evolution and monitor their own lag and failure paths.
Independent reactions do not create one cross-service atomic transaction. Use a workflow/saga and compensating actions when needed, with a clear owner and recoverable state. An event log is not automatically a complete event-sourced model.
Work through an example
BookingConfirmed has receipt, analytics and loyalty subscribers.
Reason with the numbers
A failed analytics consumer should not roll back a valid booking. Loyalty may remain eventually consistent, while seat ownership must stay authoritative.
Make a decision
Document each subscriber obligation and recovery/replay rules. Replaying an analytics event is different from sending every historical receipt again.
Implementation sketch
{
"id": "evt-42",
"type": "BookingConfirmed",
"version": 1,
"bookingId": "bk-17",
"occurredAt": "2026-11-20T10:00:00Z"
}Fictional event contract. Use real unique IDs, schema checks, access control and a deliberately chosen publication/durability strategy.
Where this is used
- Independent reactions to business facts.
- Integration where temporary consumer delay is acceptable.
Common mistakes
- Calling every message an event.
- Assuming global ordering across all consumers.
- Replaying side effects without a replay policy.
Practise a reasoned answer
Answer aloud or write notes before opening the reference. These prompts teach reasoning and trade-offs; they are not claimed questions from a particular company.
What do you gain and lose with events?
Choose a practice depth
- Foundation
- Explain a business fact and its reactions.
- Practical
- Discuss versioned contracts, lag and idempotent consumers.
- Advanced
- Defend workflow ownership, compensation, retained schemas and controlled replay.
Self-check rubric
- State the required user outcome and the relevant invariant.
- Explain the normal path and one failure path.
- Name a cost or consistency/latency trade-off.
- Say what you would measure or test before trusting it.
For deeper practice, connect this topic to the previous lesson and identify a shared bottleneck. A longer answer is not automatically a better answer.
Try it before viewing the solution
A loyalty consumer receives BookingConfirmed twice. What must remain true?
Check one key idea
Your explanation and interview notes
Saved only in this browser when storage is available. Export a backup from the course page before clearing browser data or moving devices.
Loading your local notes…
Official references and next reading
The explanation, fictional examples and animations are original teaching material. Vendor behavior depends on the specific product/version; use its documentation before deploying.