Book Deep Read · Fundamentals of Software Architecture · Chapter 14
Fundamentals of Software Architecture · Ch 14 · Mark Richards & Neal Ford · 2020
You place an order online and within a second the page says "Order placed." Yet at that moment the payment, the stock update, the confirmation email and the warehouse packing slip have not happened yet. They are being done in the background, each on its own. A software shape built on "acknowledge first, do the work in the background" is what the book calls event-driven architecture.
Picture an office with a notice board. The front desk takes an order, pins a note saying "new order," and turns to the next customer. Accounts sees it, collects the money, and pins "payment received." Only then does the warehouse pack the box and pin "packed," and the courier picks it up from there. Nobody is running the whole process; everyone just watches for the notes they care about.
The traditional way is a counter queue: the front desk personally walks to accounts, then to the warehouse, and only comes back to tell you "done" when everything is finished. If one window is slow, you wait; if one window closes, the whole thing stalls. When a crowd shows up, the line runs out the door.
The book describes two setups. The first is the notice-board office above: people pin notes and read notes, and nobody manages anybody. It is fast and easy to grow. A new colleague who hands out coupons just starts watching for "new order" notes, and nobody else changes a thing. The downside: nobody knows how far a given order has got. If accounts is off sick that day, the order quietly sits half done and no one notices.
The second is the dispatcher office: one dispatcher holds the checklist and hands out the jobs one at a time. "You collect the money." "Done? Good, you pack it." When something goes wrong, the dispatcher knows straight away and can retry, stop, or call in a person. The price: everyone waits on the dispatcher, and if the dispatcher falls over, everything does.
Either way, one thing can't be dodged. The front desk has already told you "success," so if the payment later fails, there must be a way to come back and tell you, and notes must never go missing along the way.
Events give you fast replies, room for huge crowds, and new features without touching old code, which is why online shops, trading systems and sensor networks love them. For a simple flow where speed matters most, use the notice board. For a long flow where every failure must be tracked and redone, use the dispatcher. The honest cost: this is one of the hardest styles in the book to test and debug, because things happen on their own in the background and replaying what went wrong is difficult.
Event-driven = answer first, let independent parts react to events in the background: the notice board is fast but nobody is in control, the dispatcher is in control but slower. Pick by whether you need speed or control.
Want the components of the broker and mediator topologies with the full order flow, the mediator's three-tier delegation, how async errors get repaired, the three places messages get lost, request-reply, and the book's star ratings? → Switch to Deep
You think the event-driven question is "should we use a message queue?" The real question is who owns the workflow. The broker topology spreads the flow across a chain of processors that broadcast to each other, and gets maximum decoupling, scalability and responsiveness for it. The mediator topology puts a central coordinator in charge of the flow, and gets back error handling, recoverability and restartability. Chapter 14 of FoSA is that trade-off, plus the three hard problems asynchrony brings: how errors get reported, how messages avoid being lost, and what to do when you do need an answer.
The fifth style in Part II, "Architecture Styles," and the second distributed one after service-based architecture (Chapter 13). It can stand alone or be embedded inside microservices and space-based architecture (Chapters 15 and 17). Real-world match: order processing, trade matching, online auctions, IoT ingestion, anything high-concurrency that has to react immediately.
The earlier styles assume a request-based model: a request orchestrator (usually the UI or an API layer) routes each request along a fixed path to request processors. "Get this customer's order history for the last six months" is data-driven, deterministic and predictable.
A lot of business, though, is not a request. It is a reaction to something that happened. The book's example is an online auction: once an asking price is announced and you bid, that bid is not a request to the system but an event. The system has to compare it with every other bid arriving at the same moment and decide who currently leads. If each bid had to run the full process synchronously before returning, thousands of simultaneous bidders would jam the line.
Leave it unsolved and response time is held hostage by the slowest step, queues balloon at peak, and every new step means rewiring the call chain. The chapter's answer: decoupled event processors that receive and process events asynchronously. That immediately creates new trouble, and half the chapter is about dealing with it.
The broker topology has no central coordinator. Message flow is spread across the processors in a chain-like broadcasting fashion through a lightweight message broker. Four components: the initiating event (the event that kicks off the flow), the event broker (holding the event channels, usually topics), the event processors, and processing events (what a processor broadcasts once it finishes: "here's what I did").
The book's order flow: the Order processor receives the initiating event, writes the order, returns the order ID to the customer, then broadcasts order-created. Notification, Payment and Inventory each subscribe and start in parallel. Payment charges the card and broadcasts payment-applied. Fulfillment hears that, picks and packs, broadcasts order-fulfilled, Shipping takes over, and so on.
One detail shows real design taste. Notification broadcasts email-sent after sending the email, even though nobody subscribes to it yet. The book calls this good practice: architectural extensibility. If someone later wants email analytics, a new processor subscribes to that topic and no existing component changes a line.
The cost is just as direct: nobody controls the overall workflow. No one knows when the order is finished. If Payment crashes, no one knows the flow is stuck. And you can't rerun the business transaction from the top, because some steps already ran asynchronously and wrote elsewhere.
The mediator topology exists to fix exactly those gaps. The components become: the initiating event, an initiating event queue, an event mediator, event channels, and event processors. The mediator takes the initiating event, generates processing events according to the flow definition, and sends them to channels dedicated to each processor, usually point-to-point queues. Processors do the work and report back to the mediator instead of broadcasting to the whole system.
Note that the messages mean different things in the two topologies. The broker passes events (it happened: order-created); the mediator passes commands (go do it: apply-payment). The mediator also holds the workflow state, so when payment fails it can stop the flow, record where it is, and restart from that point once fixed.
In practice there are usually several mediators, each owning a domain or a group of events (a customer mediator, an order mediator), to reduce single points of failure and raise throughput. On implementation, the book tiers its advice by complexity: Apache Camel, Mule ESB or Spring Integration for simple orchestration and error handling; a BPEL engine (such as Apache ODE) for complex flows with conditional and parallel paths; a BPM engine (such as jBPM) for long-running flows that need a human in the loop. It recommends classifying events as simple, hard or complex, sending every event first to a simple mediator that decides the class, and having it delegate the harder ones to a BPEL or BPM mediator.
This style relies entirely on asynchronous communication, both fire-and-forget and request-reply. Its biggest win is responsiveness. The book's example is posting a comment: synchronously, the user waits for every check to finish (seconds); asynchronously, the user gets "received" in tens of milliseconds. But the book stresses that this improves responsiveness, not performance. The time to finish the job hasn't shrunk.
The hard problem that comes with it is what happens on error. The user has already seen "posted," then the backend rejects the comment for banned words. How does the user find out?
The book brings in the workflow event pattern from reactive architecture, built on three ideas: delegation, containment and repair. When a consumer hits a bad message, it doesn't stall and retry in place. It immediately delegates the message to a workflow processor and moves on to the next one. The workflow processor tries to fix the message programmatically and, if it can, resubmits it to the original queue; if it can't, it sends it to a dashboard for a human.
The book flags a knock-on trap: the repaired message goes to the back of the line, so later messages for the same account may be processed first and order is lost. In the book's trading example, the fix is for the consumer to hold later messages for the same account in arrival order until the repair is done, then process them together.
① The message never reaches the queue, or the broker dies before B takes it: use persisted queues plus synchronous send, so the broker keeps the message in memory and on disk and the send only counts once it's stored. ② B dequeues the message and crashes before processing it: use client acknowledge mode, so the message isn't removed from the queue until B explicitly acknowledges it. ③ B fails to write to the database: use an ACID commit together with last participant support, so the message is acknowledged and removed from the persisted queue only after the write succeeds.
Broadcast is decoupling taken all the way: the sender has no idea who receives the message or what they do with it, which suits stock ticks, complex event processing and keeping data eventually consistent. When you really do need an answer (an order ID after placing an order), use request-reply: a request queue plus a reply queue, with the sender blocking while it waits. There are two ways to build it. Put a correlation ID in the message header and have the sender pick only the reply whose ID matches; the book recommends this. Or create a temporary reply queue per request, which is simpler, but at high volume the broker spends its time creating and deleting queues and slows down.
Event-driven is a technically partitioned style (one domain's logic is spread across several processors, mediators and queues), with anywhere from one to many quanta. Stars: performance, scalability, fault tolerance and evolvability 5; modularity 4; deployability, elasticity, reliability and cost 3; testability 2 and simplicity 1. The high scores come from asynchrony and decoupling: processors can run many instances consuming in parallel without dragging each other down, and new processors don't touch old code. The low scores come from nondeterminism: event paths are dynamic, so it's hard to enumerate every combination to test, and hard to replay what went wrong.
Table 1 · Broker vs mediator (pros and cons from the book's two comparison tables)
| Dimension | Broker topology | Mediator topology |
|---|---|---|
| Where the flow lives | Spread across subscriptions | Centralized in the mediator |
| Message meaning | Events (happened) · topic broadcast | Commands (to do) · point-to-point queues |
| Strengths | Decoupling, scalability, responsiveness, performance, fault tolerance | Workflow control, error handling, recoverability, restart, better data consistency |
| Costs | Nobody knows if the flow finished; hard to recover or restart; data drifts out of sync | Processors coupled to the mediator; the mediator becomes a bottleneck, lowering scalability, performance and fault tolerance; complex dynamic flows are hard to model |
| Fits | Simple flows, chasing throughput and extensibility | Long flows that must be tracked and repaired |
Table 2 · Request-based vs event-based (the book's selection criteria)
| Model | Use it for | What you get | Cost |
|---|---|---|---|
| Request-based | Well-structured, data-driven requests that need certainty (fetch a customer profile) | Determinism, control, easy testing | Response bound by the slowest step; poor scaling |
| Event-based | Action-driven work needing instant reaction and high scale (auction bids, trades) | Responsiveness and performance, scalability and elasticity, extensibility, real-time decisions | Eventual consistency only; less control over flow, uncertain outcomes, hard to test and debug |
The one-line test: do you need speed and extensibility, or certainty and control? It isn't an all-or-nothing call. The book notes most systems are hybrids: in one application, queries use the request model and the chain reaction after an order uses events. Event-driven messaging is also a common integration glue inside other styles such as microservices and space-based architecture.
In an architecture review, ask four things. When this flow fails, who notices? After the user has been told "success," how is a failure reported? Where are the three points a message can be lost, and what guards each? Will the mediator become a bottleneck, and has it been split by domain? In an interview, if asked "why make order placement async?", you can say: "Only writing the order and returning the ID is synchronous; payment, inventory and notification run on events. If the flow must be tracked, add an orchestrator; for maximum throughput, broadcast on topics; and guard against loss with persisted queues and client acknowledgement."
① Event-driven = decoupled event processors receiving and processing events asynchronously; suited to reacting immediately to things that happened (auction bids), not to deterministic data requests.
② Two topologies: broker (no center, topic broadcast, chained relay) and mediator (central coordinator, point-to-point queues, processors report back).
③ Broker passes "events," mediator passes "commands"; in a broker, processors broadcast processing events even with no subscribers, for extensibility.
④ Broker is strong on decoupling, scalability, responsiveness, performance and fault tolerance; weak on workflow control, error handling, recovery and restart. The mediator is the mirror image.
⑤ Split mediators by domain; tier the implementation by complexity: Camel / Mule → BPEL → BPM, entering through a simple mediator that delegates.
⑥ Asynchrony improves responsiveness, not performance; the hardest problem is reporting a failure after the user has seen "success."
⑦ Workflow event pattern: delegation, containment, repair; resubmitted repairs arrive out of order, so hold later messages per account.
⑧ Three loss points: persisted queue plus synchronous send, client acknowledge mode, ACID commit plus last participant support.
⑨ Ratings: performance, scalability, fault tolerance, evolvability 5; testability 2, simplicity 1; technically partitioned, one to many quanta.
⑩ Interview line: "Only the step that must answer right away is synchronous, the rest runs on events; use a mediator for control, a broker for throughput, and persistence plus acks to avoid loss."