I'm quite new to Rabbitmq and I'm working on a system where a central router could receive a message from a client, route it to a target, and send the response to the resquestor client.
Basically, there are 3 modules, each one can send a message targeting another module. I'd like the message to have the following flow:
RabbitMQ seems a good candidate to this but I'm not sure what is the best way to implement that. Would the REQ/REP approach more appropriate ?
It sounds like a classic case of RPC
This link explains in detail (with python) how RPC in RabbitMQ works. RPC Client and RPC Server
But basically, what will happen is, from your example above:
(From RPC Client)
Module1 will connect to the RabbitMQ broker (14/17), and declare an exclusive queue (24) it will then create a basicproperties of your message and set the reply_to (26) (which is a queue name) and then publish the message into the exchange (28)
(From RPC Server)
Module 3, would subscribe to the queue which the message from Module1 would end up in and then start consuming from that queue (40) when a message is received (31) it will process it then republish the result setting the routing key to the reply_to (38) then your consumer (Module1) will need from consume from it (see rpc consumer line 42)