我尝试在一个兔子队列和另一个兔子队列之间创建一条非常简单的路由。从一个队列到第二个队列,消息应该没有任何处理。但是由于未知原因,该消息一次又一次地重定向到第一个队列,而不是转到第二个队列。
@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");
}
}
日志如下:
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
骆驼配置有什么问题?我认为这是尽可能简单的。
与其删除标题,不如在交换中使用out消息,如下所示。在这个特定的示例中,rabbitmq
前缀可能还可以,但是,如果您尝试将这种方法与其他组件一起使用(imap是一个很好的示例),则由于种种奇怪的原因,它将无法工作。
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");
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句