Pub/Sub Messaging Model
Pub-Sub messaging is an asynchronous communication method used in microservices architecture. The Pub-Sub model consists of three components.
Pub/Sub messaging allowing to create decoupled applications easily with a reliable communication method and enables users to create Event-driven architectures. Event-driven architecture (EDA) is a software design pattern that enables a system to detect events (such as a transaction or site visit) and act on them in real time or near real time. This pattern replaces the traditional Request/Response architecture where services would have to wait for a reply before they could move onto the next task.
There are two types of message distribution patterns namely Point-to-point messaging and Publish-Subscribe.
In Point-to-point messaging, there is one-to-one relation between the sender and the receiver of the message. Each message is sent and consumed only once. This pattern is used when some action needs to be performed only once. Traditional message queues use this pattern.
Recommended by LinkedIn
In publish-subscribe, the sender of the message doesn’t know anything about receivers. The message is being sent to the topic. After that, it’s distributed among all endpoints subscribed to that topic. It can be useful e.g. for implementing notifications mechanism or distributing independent tasks.
A pub/sub model allows messages to be broadcasted asynchronously across multiple sections of the applications.
The main component that facilitates this functionality is something called a Topic. The publisher pushes messages to a Topic, and the Topic instantly pushes the message to all the subscribers. This is what differentiates the Pub/Sub model from traditional message brokers, where a message queue batches individual messages until a user or service requests these messages and retrieves them.
Whatever the message is in the Pub/Sub model, it will be automatically pushed to all the subscribers. If there are user-created policies for certain subscribers then those will be filtered out.
This approach makes it possible to create event-driven services without constantly querying a message queue for messages.
Pratima Upadhyay , message buses too have high performance and provide scalable messaging solutions. What factors do you take in consideration while deciding between the two options.
Pub-Sub model is a system which simplifies async programming processes and provides a simpler and scalable solution for eventual consistent systems to scale with less resource availability. Will be great if we can get a post on system describing combination messaging queues with pub sub model, stateful and stateless load-balancers processing high throughput data in resource constraint environment and providing acceptable throughput.