"Java Message Service" book by O'Reilly Media says:
use request/reply model in point-to-point messaging.
We can use message selectors in pub/sub messaging, so writing a request/reply model is as simple as writing a simple selector on reply topic:
UUID
as correlationID
)UUID
as correlationID
UUID
sent. Is this a wrong pattern?
Publish Subscribe Messaging Model is a messaging paradigm supported by JMS (Java Message Service). It is intended to provide asynchronous message transmission between publisher and subscriber using topics. In this article, lets discuss about Publish Subscribe Messaging Model Architecture in detail.
Another difference is in the point-to-point model, the message sender must know the receiver but in the publish/subscribe the message publishers do not need to know where the message will be consumed. This characteristic provides a high decoupling for the application when applying the publish/subscribe message model.
Messages are sent (pushed) from a publisher to subscribers as they become available. The host (publisher) publishes messages (events) to channels (topics).
The two we'll look at are request-response and publish-subscribe. The typical model for computers communicating on a network is request-response. In the request-response model, a client computer or software requests data or services, and a server computer or software responds to the request by providing the data or service.
Request/Reply messaging pattern is typically used for invoking a service hosted by service provider. Based on service request, a provider will reply with an appropriate response. So it's one-to-one. Here requestor and responder know each other.
In case of pub/sub, publisher and subscriber do not know each other. There could be a number of publisher publishing on a topic and there could be thousands of subscribers listening for that topic. So after receiving publication, if a subscriber replies to request using a topic, then that publication could go to a number of subscribers. Such a thing might flood the network.
In my opinion Request/Reply model must be used in P2P messaging and not Pub/Sub.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With