liveBook · Manning

Chapter 7: Event-Driven Architecture (EDA): Temporal Decoupling and Asynchronous Communication

What you will learn in chapter 7 of Grokking Software Architecture

This chapter introduction previews topics in event-driven architecture without explaining them.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This chapter introduction previews topics in event-driven architecture without explaining them.

Introduction

This section explains how synchronous service calls create temporal coupling, making an entire purchase flow vulnerable to one unavailable service.

Key terms: Temporal Coupling, synchronous system, Dependency Chain, distributed monolith, Orchestration, domino effect

7.1.1 The Clarity Engineer's Fix

This subsection introduces the shift from immediate requests to notifications that other parts of a system can handle later.

Key terms: resilient systems, synchronous chains

7.2 Core Components & Publish-Subscribe

This section explains why event-driven communication uses a message broker to let services collaborate without waiting for one another.

Key terms: Message Broker, Dependency Dominoes, synchronous technical loop

7.2.1 The Players

Defines the producer, broker, and consumer roles in event-driven messaging and gives a practical rule for choosing broker infrastructure.

Key terms: Producer, Publisher, Broker, Consumer, Subscriber, persistence, managed service, ops overhead, RabbitMQ, Kafka

7.2.2 Command vs. Event (The Vocabulary)

This section distinguishes commands from events by their intent, audience, expectations, and coupling, then notes a transaction difficulty with events.

Key terms: command, event, High Coupling, Low Coupling, Events, strict transactions, Rollback

7.2.3 The Publish-Subscribe Pattern (Pub/Sub)

This section explains how publish-subscribe lets services react to an order event without the Order Service calling them directly, and identifies the consistency tradeoff.

Key terms: Publish-Subscribe (Pub/Sub), Publishers, Subscribers, topics or channels, OrderPlaced, Chained model, Open-Closed Principle (OCP), Order Service, Rewards Service, Analytics Service

7.3 Eventual Consistency (The Art of Being Late)

This section explains how asynchronous event processing can leave a user seeing temporarily outdated information, and frames that delay as a consistency tradeoff of decoupling.

Key terms: Event, Immediate Consistency, Availability, ACID, BASE, Eventually Consistent

7.3.1 The Lie We Tell Ourselves

This subsection contrasts the expectation of instant updates everywhere with eventual consistency, where data may be temporarily stale but converges after updates stop.

Key terms: Strictly Consistent, Eventual Consistency, high availability

7.3.2 The "Coffee Shop" Analogy

Uses a coffee-shop analogy to show the tradeoff between immediate consistency and non-blocking scalability, then gives a rule for deciding where delayed updates are acceptable.

Key terms: synchronous, blocking, eventually consistent, non-blocking, queue, immediate consistency, eventual consistency, Total Likes

7.3.3 The "Panic Gap" (Read-Your-Writes)

This subsection shows how delayed event processing can make a recent user action appear lost, and how an immediate UI placeholder can make the wait understandable.

Key terms: Read-Your-Writes problem, Producer, Consumer, OrderPlaced, Client-Side Intelligence, Optimistic UI, Processing... placeholder

7.3.4 Connecting the Dots: The CAP Theorem Returns

This section connects eventual consistency to an availability tradeoff and shows why slow AI work belongs in an asynchronous consumer rather than a user-facing request.

Key terms: Eventual Consistency, CAP Theorem, AP System, Availability, Partition Tolerance, Consistency, AI Agent, Consumer, Controller, Queue

7.3.5 CAP Theorem Revisited: Why “Pick 2 out of 3” is (Mostly) a Lie

This section replaces the simple “pick two” version of CAP with context-dependent partition decisions, PACELC’s everyday latency tradeoff, and explicit recovery planning.

Key terms: CAP, Consistency, Availability, Partitions, CA, single region, latency, timeout, Partition Decision, Order Service

7.4 The Event Lifecycle

Defines the event lifecycle as a durable, multi-stage journey and contrasts it with a synchronous request-response exchange.

Key terms: Event Lifecycle, Published, Persisted, Consumed, Acknowledged

7.4.1 The Distribution Patterns: Queue vs. Topic

This section contrasts queues and topics by how they distribute messages and the work each pattern suits.

Key terms: Queue, Topic, Point-to-Point, Publish/Subscribe, Consumer, Subscriber

7.4.2 The Four Operational Realities of Event Streams

Explains four operational constraints of event streams—partitioning, ordering, delivery guarantees, and backpressure—and the design choices they require.

Key terms: Partitions, Shards, Partition Key, Horizontal Scale, Ordering, logical sequence numbers, timestamps, out-of-order events, At-Most-Once, At-Least-Once

7.4.3 The Four Stages of Flow

Traces an event through publication, broker storage, consumption, and acknowledgment, then explains why retrying unacknowledged work can cause duplicate processing.

Key terms: Publication, Enqueue, Consumption, Acknowledgment, Broker, Persistence, At-Least-Once Delivery, Resilience, Duplicate Processing, ACK

7.4.4 The Safety Valve: Dead Letter Queues (DLQ)

This section explains how dead letter queues stop repeatedly failing messages from clogging a queue while preserving them for investigation.

Key terms: Poison Pill, Infinite Death Loop, Consumer, Broker, MaxDeliveryCount, Dead Letter Queue (DLQ), Poison Queue, Retry Policy, DLQ, monitor

7.4.5 The Hidden Trap: The Fan-Out Storm

This section explains how a surge of events can overwhelm consumers and a database, and how to control the flow of work without abandoning asynchronous processing.

Key terms: fan-out, lock contention, connection limit, Prefetch Limits, Throttling, QoS, unacknowledged messages, Producer, batches, queue as a shock absorber

7.5 Code Snippet: Event Definition (The POCO)

This section distinguishes the simple event payload from the infrastructure and dispatcher that move it.

Key terms: Event, payload, POCO, Broker, Dispatcher

7.5.1 The Golden Rules of Event Design

This section explains how to design event messages and identifies two delivery hazards: duplicate messages and unreliable database-and-broker writes.

Key terms: Past Tense Naming, OrderPlaced, Schema Versioning, Immutability, Broker, record, Value Equality, separation of concerns, Duplicate Detection, Message ID

7.5.2 The "VIP Badge": The Marker Interface

This section explains why an empty IEvent interface marks which objects may be published as events.

Key terms: IEvent, empty interface, Events, Compiler, message bus

7.5.3 The Breadcrumbs: Correlation ID

This section explains how a correlation ID links the logs of one request across asynchronous services.

Key terms: CorrelationId, Correlation ID, Stack Trace, GUID

7.5.4 The Architectural Footprint: Where does this code live?

Shows how to recognize event-driven architecture in a codebase and where its event contracts, publishing boundary, and message handlers belong.

Key terms: Shared Contracts, Core.Shared, Contracts, OrderPlaced, Producer, Consumer, IEventPublisher, outbound Port, Adapter, Core Domain

7.6 The Dork Side: “Houston, We Have a Stack Trace!”, the Real Life Story of Apollo 13

This introduction argues that logs become essential when a complex, distributed system fails, setting up the Apollo 13 story.

Key terms: distributed system, logs

7.6.1 The Hidden Bug (Technical Debt)

This subsection uses the Apollo 13 oxygen tank failure to show how an overlooked change can become technical debt with catastrophic consequences.

Key terms: Technical Debt, Legacy Code, thermostat switches, Oxygen Tank No. 2

7.6.2 The Incident: "Main Bus B Undervolt"

The section recounts the Apollo 13 oxygen-tank explosion, the resulting telemetry warnings, and the engineers’ initial dismissal of those warnings.

Key terms: telemetry, Main Bus B Undervolt, Cryo Pressure Decreasing, Denial

7.6.3 The Debugging: Sy Liebergot’s Correlation

An Apollo 13 debugging story shows how correlating event streams can reveal a shared cause when direct debugging is impossible.

Key terms: event streams, Event Stream, logs, correlate

7.6.4 The "Hotfix": The Square Peg in a Round Hole

The Apollo 13 CO2 scrubber problem illustrates how a tested adapter can serve as an imperfect but effective production hotfix under severe constraints.

Key terms: Command Module, Lunar Module, CO2 scrubber canisters, adapter, mailbox rig, Hotfix, production environment

7.6.5 The Legacy: Why We Log

This section uses the Apollo 13 story to explain why observability, correlation IDs, and queued messages matter when systems fail.

Key terms: Telemetry, Distributed Systems Observability, Correlation IDs, log statements, Queue, Redundancy, backup

7.7 In-Action Mission: Triggering Real-Time AI Inference

Sets up a toxicity-filter exercise that tests whether posting can return immediately despite a slow AI assessment.

Key terms: Temporal Decoupling, Toxicity Filter, Immediate Success, Large Language Model (LLM)

7.7.1 The Mission Brief

This mission brief specifies a console-app simulation in which an API acknowledges a comment immediately while a background AI consumer processes it after a delay.

Key terms: CommentPosted, CorrelationId, CommentText, System.Threading.Channels, Producer (API), Consumer (AI Agent), Time to First Token, GPU Crunch, LLM latency

7.7.2 Acceptance Criteria (The Rules)

Sets the observable pass criteria for a non-blocking comment producer and a later AI result.

Key terms: No Blocking, Producer, The Gap, CorrelationId, Producer log, AI log

7.7.3 The Target Output

This section shows what console output should demonstrate for the event-driven AI exercise and how to simulate the processing delay without an AI service.

Key terms: Correlation ID, Producer, Consumer, 200 OK, Thread.Sleep(3000), OpenAI API key, topology

7.8 Checklist

This section provides self-check questions for reviewing the chapter’s event-driven architecture concepts.

7.9 Recap

The recap connects asynchronous events, producer–broker–consumer roles, eventual consistency, and event safety and observability into a picture of event-driven architecture.

Key terms: Event-Driven Architecture (EDA), Producer, Broker, Consumer, Temporal Coupling, Choreography, Eventual Consistency, PACELC, Latency, Consistency

Where this is used later

Concepts explained in this chapter

← Chapter 6: Reliable API Design: Public Contracts and Synchronous Communication Chapter 8: The Database as an Architectural Pillar: Choosing Between Strict Order and Massive Scale →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.