we need to run a function on a remote computer and wait for the result? - RPC
Screen Shot 2020-07-22 at 4.50.52 PM
callback queue
A client sends a request message and a server replies with a response message. In order to receive a response the client needs to send a 'callback' queue address with the request.
create callback queue per client
use correlation_id , match response with request; unknown correlation_id , simply discard
Screen Shot 2020-07-22 at 4.52.56 PM
workflow
When the client starts up, it creates an anonymous exclusive callback queue.
For an RPC request, the Client sends a message with two properties: reply_to, which is set to the callback queue and correlation_id, which is set to a unique value for every request.
The request is sent to an rpc_queue queue.
The RPC worker (aka: server) is waiting for requests on that queue. When a request appears, it does the job and sends a message with the result back to the Client, using the queue from the reply_to field.
the client waits for data on the callback queue. When a message appears, it checks the correlation_id property. If it matches the value from the request it returns the response to the application.