Reputation: 5745
"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?
Upvotes: 6
Views: 3159
Reputation: 15283
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.
Upvotes: 2