I try to create a very simple route between one rabbit queue and another one. Message should go with no processing from one queue to the second. But for unknown reason the message is redirected to the first queue again and again instead of going to the second one.
@Component
public class CamelRouter extends SpringRouteBuilder {
@Override
public void configure() {
from("rabbitmq://localhost/test-in?autoAck=false&autoDelete=false&durable=true&exchangeType=fanout&queue=test-in&username=guest&password=xxx")
.log(LoggingLevel.ERROR, "Output of message from Queue: ${in.body}")
.to("rabbitmq://localhost/test-out?autoAck=false&autoDelete=false&durable=true&exchangeType=fanout&queue=test-out&username=guest&password=xxx");
}
}
The logs are following:
09:04:18.564 [thread] WARN route1 - Output of message from Queue: test
09:04:18.700 [thread] WARN route1 - Output of message from Queue: test
09:04:18.835 [thread] WARN route1 - Output of message from Queue: test
09:04:18.968 [thread] WARN route1 - Output of message from Queue: test
09:04:19.104 [thread] WARN route1 - Output of message from Queue: test
09:04:19.238 [thread] WARN route1 - Output of message from Queue: test
What is wrong is this camel configuration? It's as simple as possible in my opinion.
Instead of removing the headers, it's better to use the out message on the exchange as shown below. In this particular example the rabbitmq
prefix is probably ok, however if you try this approach with other components (imap is a great example) it wont work for all sorts of strange reasons.
from("rabbitmq://localhost/test-in?autoAck=false&autoDelete=false&durable=true&exchangeType=fanout&queue=test-in&username=guest&password=xxx")
.log(LoggingLevel.ERROR, "Output of message from Queue: ${in.body}")
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getOut().setBody(exchange.getIn().getBody());
}
})
.to("rabbitmq://localhost/test-out?autoAck=false&autoDelete=false&durable=true&exchangeType=fanout&queue=test-out&username=guest&password=xxx");
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments