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 MP4Captions

Listen without the videoDownload audio

The same pre-recorded voice as the video. Starting audio pauses the video, and starting the video pauses audio.

Chapters 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.

Booking ownerEvent channelReceipt consumerAnalyticsLoyalty

Step 1 of 6 · Event: BookingConfirmed

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
  1. 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.

  2. 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.

  3. One subscriber lags

    Analytics becomes slow while receipt processing continues. Subscriber delay is observable; it should not silently redefine the original booking outcome.

  4. Deliver the event twice

    A repeated delivery uses the same logical event identity. Consumers must avoid awarding points or producing another external effect accidentally.

  5. Evolve the contract

    Add compatible fields carefully and test old consumers. Retained events and delayed subscribers may outlive the latest deployment.

  6. 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?

Answer aloud or write your reasoning in the lesson notes before revealing the explanation.

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

A paper or whiteboard task. No cloud account or paid infrastructure is required.

  1. Classify ConfirmBooking as a command and BookingConfirmed as a fact.
  2. Draw receipt, analytics and loyalty subscribers.
  3. 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.

These checkboxes reset when you leave. Use your saved lesson notes and completion marker to record lasting progress.

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.

Try it before viewing the solution

A loyalty consumer receives BookingConfirmed twice. What must remain true?

Check one key idea

Which is a fact rather than a command?

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.