← All patterns
Messaging · Architecture pattern

Publish–Subscribe

Deliver one published event to independent subscriptions with their own progress.

The problem

A completed order must update analytics and trigger notifications without the producer calling both systems directly.

When it fits

Several independent consumers need the same event and can handle asynchronous delivery.

The whole architecture

Architecture diagram

One published event is copied into independent subscriptions; each subscriber owns its own progress.

Purple arrows are asynchronous event delivery. Workers within one subscription compete for its messages.

100%

Scroll to pan. Select a component for its role.

publish subscribe architectureOne published event is copied into independent subscriptions; each subscriber owns its own progress. Purple arrows are asynchronous event delivery. Workers within one subscription compete for its messages.Analytics subscriptionNotification subscriptionpublisher → topic: publishtopic → analytics-sub: copytopic → notify-sub: copyanalytics-sub → analytics: deliver / ACKnotify-sub → notifications: deliver / ACKpublishcopycopydeliver / ACKdeliver / ACKPublish a fact without calling every interested consumer.PublisherStable business eventFan-out supplies independent deliveries under the chosen broker contract.Topic / brokerSubscription routingAnalytics progress does not advance notification progress.Analytics subIndependent cursor / ACKA stalled subscription needs its own retention and recovery policy.Notification subIndependent cursor / ACKWorkers within this subscription share its work.Analytics handlerSubscriber worker poolDuplicate delivery still needs effect protection.NotificationhandlerSubscriber worker poolThese policies belong to an explicit messaging contract.Delivery policiesRetention, retries, ordering and duplicate handling

Select a component, or focus it and press Enter, to read its role.

Walk through the design

Follow one operation

Select a step to highlight its participants. This conceptual walkthrough is separate from challenge scoring.

Each outgoing topic branch is an independent subscription, rather than another worker in the same subscription.

PublisherActive in this stepTopicActive in this stepAnalytics subWaitingNotification subWaiting
Step 1 of 3

Publish a fact

Producer emits a stable event describing a completed operation.

Trade-offs to make explicit

  • Separate subscriptions let consumers progress independently; fan-out adds storage, delivery and operations cost.
  • Workers inside one subscription can share work. Independent subscriptions each receive the event under the chosen broker contract.

Failure modes to plan for

  • An acknowledgment can be lost after processing, causing redelivery to that subscription.
  • A slow subscription needs retention limits and recovery; one consumer catching up does not prove every subscriber is current.
Before you build

Explain your decision

How would you distinguish two independent subscriptions from two workers competing in the same subscription?

Use Plan & estimate inside practice to record your assumptions and trade-offs.

Connect concept to practice

Related challenges

Browse challenges →

These links open the original challenges. Existing round unlocks, completions and points apply.

One provider stalled; the others still deliver

Related practice in independent delivery and idempotency. It does not simulate topic subscriptions or broker fan-out.

Open challenge →

Further reading

Microsoft · Publisher-subscriber ↗

Original PractiseGrid explanations and conceptual diagrams, with primary references for further study. Dedicated scored exercises can be added as coverage grows.