Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

communication
service

Publish/subscribe (pub/sub) messaging

Educative Answers Team
svg viewer

What is publish/subscribe (pub/sub) messaging?

pub/sub messaging is a form of asynchronous communication between application services. Pub/sub offers a highly available, consistent messaging service that is effectively scalable. The services that use pub/sub methodology exchange messages without the knowledge of the sender or the receiver – it essentially broadcasts the messages to all the parties and then the services fetch the desired messages according to their subscriptions. There are four components of the pub/sub messaging service:

  1. Publisher
  2. Subscriber
  3. Message
  4. Topic
svg viewer

1. Publisher

The Publisher is responsible for sending the message to the intermediary broker, i.e., Topic. The Publisher does not know the recipient, but it gets pinged if the message delivery to the Topic is not successful.

2. Subscribe

The Subscribers sign up to the topics of interest. They receive messages directly from the message broker (Topic) without any hint of the service that published that message.

3. Message

The Message is the actual content of interest for the Publishers and Subscribers. These messages are serialized before being sent to Topic by the Publisher. The messages content is comprised of data and attributes (optional).

4. Topic

The Topic is the message broker that serves as the middle-man between the Publishers and the Subscribers. It receives the messages from the Publishers and buffers the message queue until the subscribers to the topic receive the message and send an acknowledgment back. Upon getting the acknowledgment, the service removes the message from the subscribers messaging queue.

RELATED TAGS

communication
service
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring