October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Publish/Subscribe Messaging: How Pub/Sub Works and When to Use It

Publish/subscribe messaging routes a publisher’s messages through an intermediary to interested subscribers, enabling asynchronous, decoupled communication.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Publish/subscribe messaging (pub/sub) is an asynchronous pattern in which publishers send messages to a topic or channel, and messaging infrastructure routes them to subscribers interested in that topic. The publisher does not need to know who the subscribers are or where they run.

How publish/subscribe messaging works

Pub/sub has four basic roles:

  • Publisher: creates and sends a message or event.
  • Topic or channel: identifies a category or stream of messages.
  • Subscriber: registers interest in a topic, channel, or filter.
  • Broker or router: tracks subscriptions and routes matching messages to subscribers.

Usually, subscribers register first. A publisher then sends a message to the topic or intermediary, and the infrastructure selects the matching subscriptions and delivers it. The result is often one-to-many distribution, though routing and delivery details depend on the system.

As an Amazon Associate I earn from qualifying purchases.

Example: an order event

When an order service publishes an order-placed event, inventory, fulfillment, and analytics services could each subscribe to it. The messaging infrastructure distributes the event to those subscribers, while the order service remains unaware of their identities. A new subscriber can be added without changing the publisher.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What pub/sub is useful for

Pub/sub separates message production from consumption. Publishers and subscribers can evolve, scale, and operate more independently, and subscribers can process events asynchronously. A single publication can also trigger multiple independent workflows in parallel.

Topic- or content-based filters can direct messages to interested subscribers rather than delivering every message to every consumer. This pattern is useful when a state change should notify several components, when work does not need to finish before the sender continues, or when a broadcast does not require an immediate reply.

How pub/sub differs from a queue and request-reply

Pattern Typical purpose What the sender should expect
Pub/sub Distribute a publication to multiple interested subscribers Usually asynchronous delivery; publishing alone does not provide a synchronous answer
Queue Hold work until it can be processed, often by a consumer taking responsibility for a message Typically work-oriented processing rather than fan-out to every interested subscriber
Request-reply Obtain an answer to a request A response path is part of the design when the sender needs a reply

These are common distinctions, not rigid rules for every product. Some messaging services combine or blur queue and pub/sub behavior, so check the chosen service’s routing and delivery semantics. If the sender needs an immediate, synchronous response, use a request-reply design rather than treating publication as a call that returns an answer.

What pub/sub does not guarantee by itself

The pattern alone does not ensure that every subscriber is available or receives every message. A message may be transient, delivery may be delayed, and subscribers may miss messages while disconnected. Delayed delivery can also leave parts of a system temporarily out of sync, a condition known as eventual consistency.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If subscribers must recover missed work, check whether the implementation supports persistence, acknowledgements, retries, replay, and message retention. Delivery guarantees and message time-to-live (TTL) vary. Pub/sub is a poor fit when a workflow requires an immediate, strongly consistent answer from all receivers.

Questions to check before choosing a pub/sub system

  • Delivery: What guarantees are offered? How are retries, acknowledgements, and duplicate messages handled?
  • Ordering: Is message order guaranteed, and is ordering needed per key or across the entire system?
  • Recovery: What persistence, retention, TTL, and replay options are available for disconnected subscribers?
  • Routing: What fan-out capacity, filtering, and subscription-management features are provided?
  • Security: How are publishers and subscribers authenticated and authorized, and how is message data protected in transit and at rest?
  • Operations: Do latency, expected scale, operational effort, and cost fit the workload?

These are implementation-specific comparison points, not features guaranteed by the pub/sub pattern.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

MQTT is one protocol that uses pub/sub

MQTT is a protocol built around publish/subscribe messaging, not another name for the pattern. The OASIS MQTT Version 5.0 Standard, published on 7 March 2019, describes MQTT as a client-server publish/subscribe messaging transport protocol designed for contexts that include constrained environments. It specifies three quality-of-service levels: at most once, at least once, and exactly once. Those delivery levels are MQTT specification details and should not be assumed of other pub/sub systems.

Rank #4
Sale
ZeroMQ: Messaging for Many Applications
  • Used Book in Good Condition

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.