Theory · Page 30 of 34 · Pipeline patterns

30. Fan-out: one event, many independent consumers

Fan-out delivers one event to many independent consumers, each reading at its own pace from its own position. Its one rule is isolation: one consumer's failure, slowness or bad message must never stop the others.

One event, four independent consumers
Playback speed

The clip publishes each ClaimReported event once and delivers it to four consumers: acknowledgement letters, fraud scoring, finance staging and the search index. The search index goes down from 09:10 to 09:20, and the fraud model fails on the claim whose policy does not exist; after three retries that event goes to the fraud consumer's dead-letter queue. With each consumer isolated, the others carry on and only search waits; with one process calling all four in turn, everyone waits for the slowest. The counts at 09:16 show the difference.

The intuition: four newspapers, not one relay

Four Harbour Mutual teams need to know when a claim is reported: the letters team, the fraud team, finance and the people who run the search index. The claims portal could call each in turn, and wait for each to answer. Then the day the search index is down, nobody gets anything, because the portal is stuck waiting on the third call.

Fan-out works like a newspaper: the portal publishes each event once, and each team has its own subscription and reads it when it can. If one team is away for a morning, its papers pile up on its own doormat and the others read theirs as usual.

Remember Publish once; give every consumer its own subscription, position and dead-letter queue, so a failure stays where it happened.

How it works, step by step

The producer writes each event once to a topic or log. Each consumer has its own subscription or consumer group, which records its own offset, how far it has read. Consumers do not know about each other, and the producer does not know about them.

Consumer isolation follows: a consumer that is down simply stops moving its offset; the events wait for it in the log or its subscription, and the others keep reading. When it comes back, it reads on from where it stopped and catches up.

A poison message, an event one consumer cannot process, is handled by that consumer alone: it retries a few times in case the failure is temporary, then moves the event to its own dead-letter queue for someone to inspect, and carries on with the next. Without a dead-letter queue, it retries for ever and nothing behind that event is handled.

The opposite design, where one process calls every consumer in turn and moves on only when all succeed, is coupled: the slowest or failing consumer sets the pace for all of them.

Done by 09:16, of the ten events (computed)
ConsumerIsolatedCoupledIsolated, no dead-letter queue
Acknowledgement letters747
Fraud scoring633
Finance staging747
Search index434

By hand

Deliver the ten events to the four consumers. Each takes ten seconds an event; the search index is down from 09:10 to 09:20; the fraud model fails on E04 and retries 3 times.

The ten events
EventClaimPolicyReportedReached the logAmountNote
E01C-201P-100109:01:4009:02:10€1,200–
E02C-202P-100209:0409:04:50€2,400–
E03C-203P-100309:06:3009:07:45£800health details
E04C-204P-999909:0909:09:40€650–
E06C-206P-100609:14:2009:15:05€950–
E07C-207P-100709:14:5009:15:12€4,200–
E08C-208P-100809:1509:15:20€700–
E09C-209P-100909:18:3009:19:10€1,500–
E05C-205P-100509:12:1009:21:30€3,100–
E10C-210P-101009:2409:25:40€2,600–
  1. Isolated: the fraud consumer meets E04 at 09:09:40. What does it do, and does it stop?
    Predict the result, then check it It retries 3 times, sets E04 aside in its dead-letter queue and carries on; 1 event in its queue by the end.
  2. Isolated: how many events has fraud scoring finished by 09:16, and the search index?
    Predict the result, then check it Fraud 6; search 4, because it is down.
  3. When does the isolated search index finish its last event?
    Predict the result, then check it At 09:25:50: it catches up after 09:20 from its own offset.
  4. Coupled: one process calls all four in turn. How many has fraud scoring finished by 09:16?
    Predict the result, then check it Only 3: every consumer waits while search is down.
  5. Isolated without a dead-letter queue: how many events does the fraud consumer never reach?
    Predict the result, then check it 7: it retries E04 for ever.

What you found: Isolated, a failure delays only the consumer it happens to: by 09:16 fraud has 6 events done against 3 when coupled.

Why this step
Publish once, to a topic or log
Without it: The producer must know every consumer and call each, and a new consumer means changing the producer.
Give each consumer its own subscription and offset
Without it: One slow consumer holds back all the others.
Retry, then dead-letter
Without it: A single bad event stops a consumer for ever, or is silently lost.
Watch each consumer's lag
Without it: A consumer that has stopped is noticed only when its readers complain.
People often think…
If one consumer fails, the event has failed.
In fact: The event is fine; one consumer's handling of it failed. Isolated, the other three handled all ten events.
A dead-letter queue loses data.
In fact: It keeps the event aside, with the reason, for someone to fix and resubmit; here 1 event waits there.
Fan-out means copying the data many times.
In fact: The event is stored once in the log; each consumer only records how far it has read.

When it fits, and when it does not

  • Fits: one business event that several teams need for different reasons, and consumers that must not depend on each other.
  • Does not fit: a step that must succeed or fail with another in one transaction; that is one consumer doing two things, not two consumers.

Design notes

Give every consumer its own dead-letter queue and an owner who empties it. Alert on lag per consumer, not per topic. Keep the event's schema under a contract (page 17), because every consumer depends on it.

Why it matters

Fan-out is how one claim event can serve letters, fraud, finance and search without the four teams coordinating releases. It is also where an organisation learns whether its consumers are truly independent: the first outage tells.

On Azure (checked against Microsoft Learn on 24 October 2026)

  • Azure Event Hubs: each reader is a consumer group with its own offsets; up to 20 consumer groups an event hub on Standard, 100 on Premium.
  • Azure Service Bus topics: each subscription gets its own copy and has its own dead-letter queue; a message moves there after its maximum delivery count, 10 by default.
  • Azure Event Grid pushes each event to every matching subscription, retries with back-off, and dead-letters to a storage account if you configure one.

Where it goes wrong

  • Consumers sharing one group. Two teams read with one offset, and each gets only some of the events.
  • Calling consumers in a chain. The first failure stops the rest.
  • No dead-letter queue. One bad event blocks a consumer for ever.
  • A dead-letter queue nobody empties. Events wait there for months.
You can now…
  • Explain why each consumer needs its own subscription and offset.
  • Trace a consumer's outage and catch-up by hand.
  • Say what a dead-letter queue is for and who owns it.
  • Tell an isolated fan-out from a coupled chain by what happens when one part fails.

Check yourself

Choose an answer to each question, then press Check.

1. The search index is down from 09:10 to 09:20. Isolated, what happens to the letters consumer?
2. What does a consumer do with an event it cannot process after its retries?
3. Why does a coupled chain do worse in an outage?
Answer every question first.

Sources

The works this page draws on, summarised in its own words rather than quoted. Read them for the full argument.

  • G. Hohpe and B. Woolf, Enterprise Integration Patterns (Addison-Wesley, 2003)Publish-subscribe channels, competing consumers and dead-letter channels.
  • Microsoft Learn: Service Bus dead-letter queuesEach queue and subscription has its own dead-letter subqueue; the maximum delivery count is 10 by default.
  • Microsoft Learn: Azure Event Hubs quotas and limitsConsumer groups per event hub and retention by tier.

Practise it

The chapters that put this theory to work on Harbour Mutual and Kestrel:

The tools to try it in:

  • Pipeline patterns lab · Run the same claim events through eight pipeline patterns and see latency, overhead, a consumer failing, a delivery repeated and a logic change replayed.

Terms taught here: Fan-outConsumer groupDead-letter queuePoison message

An unhandled error has occurred. Reload 🗙

Reconnecting…

Your connection to the Cloud Data Architecture Lab dropped, probably a Wi-Fi blip. Hold on while it reconnects.

The connection could not be restored. The page will reload in a few seconds.