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:
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.
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.
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).
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.