Publish-subscribe
What Is Publish-subscribe?
Publish-subscribe is an asynchronous messaging paradigm in which senders of messages, called publishers, do not address messages directly to specific receivers. Instead, publishers classify messages by topic or content, and a separate class of participants, called subscribers, express interest in receiving messages matching particular criteria. A broker or event bus sits between them, routing each published message to every subscriber whose registered interest it satisfies. The paradigm is a foundational pattern in distributed systems design because it decouples the parties communicating: publishers have no knowledge of who subscribes, subscribers have no knowledge of who publishes, and neither party depends on the other being online at the same moment.
Formal analysis of publish-subscribe semantics has been an active area of distributed computing research, with IEEE work on modeling publish-subscribe communication systems establishing rigorous descriptions of how brokers match and forward messages. The paradigm draws on earlier event-driven programming models and extends them to networked, multi-party settings where the number of participants and their locations are not fixed in advance.
Core Components and Roles
Three roles define the publish-subscribe paradigm. The publisher generates events or data items and sends them to a channel without naming any intended recipient. The subscriber registers a standing interest with the broker and passively receives messages that match that interest, rather than polling a sender. The broker occupies the central position: it accepts published messages, evaluates them against all active subscriptions, and delivers copies to every matching subscriber.
Channels are organized by topic in the most common configuration. A publisher posts a message to a named topic; every subscriber registered for that topic receives it. More expressive variants use content-based routing, where the broker examines message attributes and applies filter predicates set by each subscriber. This lets subscribers receive precisely the data they need without the overhead of consuming and discarding unwanted messages.
Decoupling and Its Consequences
The defining architectural property of publish-subscribe is threefold decoupling. Spatial decoupling means publishers and subscribers need not know each other's network addresses or even each other's existence. Temporal decoupling means they do not need to be available simultaneously; the broker holds messages for offline subscribers when configured to do so. Synchronization decoupling means the publisher does not block waiting for a subscriber to acknowledge receipt.
These properties make publish-subscribe well suited to systems where components are developed and deployed independently, where the consumer population is large or variable, or where reliable delivery under intermittent connectivity is required. As the publisher-subscriber pattern documentation from Microsoft Azure Architecture Center notes, the pattern also isolates faults: a subscriber failure does not affect the publisher or other subscribers, and the broker retains messages until a recovered subscriber is ready to process them.
Delivery and Quality of Service
Publish-subscribe implementations vary in the delivery guarantees they provide. At-most-once delivery is lightweight but can lose messages if the broker or subscriber fails during transit. At-least-once delivery ensures every message reaches its destination but may produce duplicates, requiring subscribers to process messages idempotently. Exactly-once delivery eliminates duplicates but demands additional coordination between publisher, broker, and subscriber, adding latency. The appropriate guarantee depends on the application: sensor telemetry may tolerate occasional loss, while financial transaction events generally cannot.
AWS pub-sub messaging describes how fanout delivery, where a single published message is replicated to many subscriber queues or endpoints simultaneously, enables high-throughput event-driven architectures that would be impractical using direct point-to-point connections.
Applications
Publish-subscribe has established roles in a wide range of technical domains, including:
- Real-time data streaming in financial markets and trading platforms
- IoT telemetry collection from sensor networks to analytics pipelines
- Microservices coordination in cloud-native application architectures
- Notification and alert distribution in monitoring and operations platforms