You have to implement Remote procedure call (RPC) pattern using rabbitmq queues. In order to receive a response, the client needs to send a 'callback' queue address with the request.
Basic steps:
- In your client app create a queue to get a response and subscribe for it.
- Add additional properties to each rabbitmq message you want to get a response: reply_to - queue name to send a response (queue name from p. 1), correlation_id - id to distinguish your request (in erlang it can be a pid).
- Server app process message and publish a response to the queue from p.1 with the same correlation id.
- Client app queue listener gets a response and sends an erlang message to the pid from correlation_id.
- Your gen_server gets the response message.
Correlation id provides you the ability to create only one response queue.
You can read it in details in documentation https://www.rabbitmq.com/tutorials/tutorial-six-elixir.html
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…