Reputation: 2908
I've been looking at some server-side Java which uses JMS to interface with the ApolloMQ message broker. Clients make synchronous requests with this server by doing the following:
It seems like issuing a new temporary queue for each request may be expensive for the message broker, and likely introduces an additional round trip for each request in order to first create the temporary destination. I don't want to spend a bunch of time verifying this myself and I was kinda hoping someone in the know could confirm this intuition. Would it be better to instead create a single temporary queue per client session and use the message/correlation id to match responses to requests?
Upvotes: 0
Views: 866
Reputation: 12988
Look at it from the performance perspective: Is a message broker optimized for sending/receiving messages or to create/remove queues?
Likewise databases are not optimized to create and drop tables on the fly; it's insert/update/delete.
So I would go the "correlation ID" way.
Update
This does not necessarily mean to put the responses in the same queue as the requests. You could have one queue for each client/session.
Upvotes: 2
Reputation: 5024
Using correlationIDs involves using selectors on message queues - this is slower than creating a temporary queue for the purposes of request response (see "Request-reply over JMS" at http://camel.apache.org/jms.html for a comparison of the various options).
Upvotes: 1