The correct time queues are unique to the client making the RPC request. We could create an RPC client to create a unique queue for each unique request, but that would be inefficient - see the first paragraph of CorrelationId here :
In the above method, we suggest creating a callback queue for each RPC request. This is pretty inefficient, but fortunately there is a better way - let it create one callback queue for each client.
Thus, the best way is to have one queue to which the RPC client receives a response and uses correlation to match the request that the RPC client makes with the result that the RPC server sends back.
... having received an answer in this queue, it is not clear which request the answer belongs to. This is when the property_id property is used. We are going to set its unique value for each request. Later, when we receive a message in the callback queue, we consider this property, and based on this we can match the response to the request. If we see an unknown correlation value, we can safely reject the message - it does not apply to our requests.
So, referring to the Summary section of the RPC tutorial:
- when starting the client creates a unique and unique queue
- when it sends an RPC request, it sets the responder_name, which is the name of the queue (so the server knows which queue the response is sent to), and also sets the correlation identifier, which is a unique value for each RPC request
- the request is sent to the RPC queue
- The RPC worker (or server) receives requests processing it, then, using the reply_to value, sends a response to the client, it also sets the correlationId
- the RPC client is waiting for a response, and when it receives it, it uses the correlation with the MATCH request response
kzhen source share