I was talking with part of my team about the responsibility for who own the Binding and Queue creation. We are using Spring framework.
In async communication they agree that the responsability to create the Binding and Queue is of the Consumer. Until here, we all agree.
But they understand that this is not true for sync (RPC - Remote Procedure Call) communication.
They prefer this model:
Producer1: Exchange, RoutingKey, Binding (RoutingKey, Queue) Producer2: Exchange, RoutingKey, Binding (RoutingKey, Queue) Consumer: Queue
- The Producer sends a command (not an event, like in the async communication). Because the Producer is the main interested in the response, the setup stays on him.
- The Consumer only needs to know about the Queue. Does not matter who sends the message to him.
However, I not see in that way.
The model that I support is:
Producer1: Exchange, RoutingKey Producer2: Exchange, RoutingKey Consumer: Exchange, Binding (RoutingKey, Queue)
- The knowledge of Binding is from who consumes the Queue, like in the async communication
- One single point to declare and change the Binding and Queue. So, this setup is done only in the Consumer but in the their approach is duplicated among the Producers. Already happen to me to change the Queue name, Binding and Queue DLQ and Routing Key DLQ, and with the setup on Consumer I changed this in one unique place.
- If you would like to implement a DLQ, it's natural that the DLQ Listener will be in the Consumer, with the Binding of DLQ and Queue of DLQ there too. Does not make sense to me declare the DLQ Binding and DLQ Queue in each Producer.
- Every example with Async and Sync (RPC) communication in the RabbitMQ official documentation follow the pattern that I support. I could't find any statement about the setup differ from async to sync communication and the reasons for that change.
- The configuration is easier to understand, because the async and sync configuration follow the same idea: Binding and Queue on Consumer.
So, what is the recommended approach?