I have a problem where I want to let Camel-RabbitMq consume from my own defined queues. Writing and reading from queues via Camel routes works but only via camels own defined queues. I cannot seem to point Camel to my defined queues on RabbitMQ.
Essential information
I'm running camel version & camel-rabbitmq V3.3.0 via Spring boot V2.3.0.RELEASE. I have 2 services running on my localhost:
- on localhost:5672 a RabbitMq v3.8.3 instance
- on localhost:15672 a RabbitMq management instance
I run these instances via a simple docker-compose file:
version: '3'
services:
rabbitmq:
image: "rabbitmq:3.8.3"
ports:
- "5672:5672"
rabbitmq-management:
image: "rabbitmq:3-management"
ports:
- "15672:15672"
On there I have created 1 exchange and 1 queue via the admin panel:
- main_exchange
- in_queue
Main_exchange and in_queue are binded to each other via routing key "in_queue_routing_key" routing key.
Problem
Now when I try to connect to read from this in_queue via a camel route:
from("rabbitmq:main_exchange?addresses=localhost:5672" +
"&passive=true"+
"&autoDelete=false" +
"&declare=false" +
"&queue=in_queue" +
"&routingKey=in_queue_routing_key")
.log("received from queue")
.to("file:done");
When I publish a message to the in_queue via the main exchange, nothing happens. The Camel route does not pick up the message.
I tried following possible solutions:
- Setting passive to true, so RabbitMq doesn't make the queue itself.
Passive queues depend on the queue already to be available at RabbitMQ.
- Setting declare to false, so RabbitMq does not declare the exchange and queue itself.
If the option is true, camel declare the exchange and queue name and bind them together. If the option is false, camel won’t declare the exchange and queue name on the server.
- Writing to the queue worked, But this didn't show up in the self defined "in-queue" via admin console:
Code example:
from("file:test")
.log("add to route")
.to("rabbitmq:main_exchange?addresses=localhost:5672" +
"&passive=true"+
"&autoDelete=false" +
"&declare=false" +
"&queue=in_queue" +
"&routingKey=in_queue_routing_key");
But the consumer route did pick up after restarting the consumer route (the one above this code example).
So it looks like the Camel-RabbitMq route defines it's queue elsewhere. How can I define that the Camel route consumes on my own defined queues and not on his own?
Sources: