I was reading RPC-Model in AMQP with RabbitMQ. The tutorial creates a temporary queue and also correlationId. Temporary queues are unique, so why should we need correlationId? I’m a JMS guy, in JMS we do request/response in two ways:
-
create temporary queue for each request/response
-
create one response queue and use
correlationIdand message selector.
can someone explain why do we need both temporary queue and correlationId in AMQP RPC model? It seems AMQP does not have something like message selector. Am I right?
Correct, temporary queues are unique to the client making the RPC request. We could create the RPC client to have a unique queue for each unique request it makes, but that would be inefficient – see the first paragraph of CorrelationId here:
So a better way is to have one queue which the RPC client gets response back on and uses the correlationId to match the request that the RPC client makes to the result that the RPC server sends back.
So referencing the Summary section of the RPC tutorial: