I'm using rabbitMq mainly in RPC mode, but I also want to copy both request and responses messages to another queue.
In the end, what I want to achieve, is the possibility for an external consummer to see all the trafic by listening to a queue, let's call it a "logging queue".
Copy incoming messages is ok, I just need to use a fanout exchange or bind my logging queue to the used exchange with the same routing key as the one used by RPC call.
But I can't manage to find a way to "fanout" messages sent via the direct reply-to feature.
So far, I understand that the response messages are sent to the default direct exchange with a generated routing_key in the form of amqp.rabbitmq.reply-to.generatedName and, since the default exchange is untouchable, I can't duplicate thoses messages.
Do you know any way to do it?
I have a solution which I would rather avoid: having the client re-send the response received from the reply-to to the "logging queue".
but that means my client is responsible of this "logging" feature and I would rather not.
by the way, even if I don't think it's relevant because it's probably a rabbitMq server configuration problem, I use Spring-AMQP client
You can't do it with fixed reply-to because there is no real queue/exchange.
You can, however, configure each
RabbitTemplateto use a fixed reply queue and a reply container to direct replies from that queue to the template.Documentation here.
Furthermore, when using this mechanism, you can configure the template's
replyAddressto be in the form of an exchange and routing key.You simply set up the template and container as normal, making the template the container's listener...
Again, this is from the documentation.