Home

Publishersubscriber

Publishersubscriber, commonly written as publish-subscribe or pub/sub, denotes a messaging pattern in which information producers (publishers) emit messages that are categorized by topics or channels, and consumers (subscribers) receive messages based on their interest. Publishers and subscribers are decoupled: publishers do not need to know who subscribes, and subscribers do not need to know who publishes. This decoupling enables scalable, asynchronous distribution of events across distributed systems.

Most implementations rely on a mediator, often a message broker, that routes messages from publishers to subscribers.

Key characteristics include loose coupling, scalability through horizontal expansion, and asynchronous delivery. Delivery semantics vary: at-most-once,

Common examples include MQTT for IoT, Apache Kafka for event streaming, Google Cloud Pub/Sub, and Redis Streams.

Publishers
publish
to
a
topic
or
channel;
subscribers
subscribe
to
topics
of
interest.
The
broker
may
offer
filtering,
durable
storage,
and
delivery
guarantees.
Some
brokerless
systems
route
messages
directly
between
peers.
Topics,
queues,
and
channels
are
common
abstractions,
with
topics
supporting
many
subscribers
and
queues
typically
supporting
load-balanced
delivery
to
a
set
of
consumers.
at-least-once,
and
exactly-once
are
supported
in
different
systems;
ordering
is
often
limited
to
topics
or
partitions.
Durability
options
allow
messages
to
persist
for
late
subscribers.
Pub/sub
is
widely
used
in
microservices,
event-driven
architectures,
real-time
dashboards,
and
notification
systems.
The
pattern
contrasts
with
point-to-point
messaging,
where
a
message
is
delivered
to
a
single
consumer.