Event-Driven Architecture for Beginners

Let a completed fact trigger later work

One committed fact, several consumers

Order transactionSave business fact and publication intent
Relay and brokerPublication can retry or be delayed
ShippingDuplicate-safe business effect
EmailOwn delivery and retry status
ReportingDerived view may lag
Order storage records a fact. Publication sends it through a broker to shipping, email and reporting. Consumers can be delayed or fail independently.

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

The process could crash between saving an order and publishing its event.
The broker delivers the same event again after a retry.

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.

Every option and consequence stays visible. Choose an option in each situation to build a revisable decision record.

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

CommandRequests a change
Authoritative historyStores accepted events if event-sourced
ProjectionBuilds a query view
ReplayRebuilds state under a safe effect rule
Command: Requests a change → Authoritative history: Stores accepted events if event-sourced → Projection: Builds a query view → Replay: Rebuilds state under a safe effect rule

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

What gap does a correctly implemented transactional outbox address?
Choose one answer. You can try again.

Answer and explanation

A business change committing without its intended publication record being saved.

The supported database transaction stores the change and outbox record together.

Check your design decision

An event might be delivered twice. Which consumer rule is safer for a non-repeatable business effect?
Choose one answer. You can try again.

Answer and explanation

Recognise repeated actions with a correctly persisted and coordinated effect rule.

Delivery retries should not silently create a second business effect.

Check the added design rule

You rebuild a query projection by replaying old purchase events. Should this unconditionally charge customers again?
Choose one answer. You can try again.

Answer and explanation

No; rebuilding state must be separate from repeating external effects.

Replay is not a new purchase authorization.

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.

    Next lesson: Serverless and Background Compute →