Apache camel 连续发送消息

Apache camel 连续发送消息,apache-camel,rabbitmq,Apache Camel,Rabbitmq,我使用Camel进行集成。我有一个用例,Camel应该将一条消息从一个队列传输到另一个队列,但它会不断地向队列发送相同的消息。请查看我的以下路线: 正在以以下方式创建消息: ProducerTemplate template = context.createProducerTemplate(); template.sendBody("direct://input", "This is a test message: "); 我有一个将消息从直接组件传输到rabbitmq队列的路由 public

我使用Camel进行集成。我有一个用例,Camel应该将一条消息从一个队列传输到另一个队列,但它会不断地向队列发送相同的消息。请查看我的以下路线:

正在以以下方式创建消息:

ProducerTemplate template = context.createProducerTemplate();
template.sendBody("direct://input", "This is a test message: ");
我有一个将消息从直接组件传输到rabbitmq队列的路由

public void configure() throws Exception {
                from("direct://input")
                .to("rabbitmq://localhost:5672/test_ip?queue=task_queue&routingKey=test_task" +
                                "&autoAck=true&durable=true&username=guest&password=guest&autoDelete=false&exchangePattern=InOut")

            }
然后我有一个路由,它将消息从
任务队列
传输到
输出队列

 public void configure() throws Exception {
                from("rabbitmq://localhost:5672/test_ip?queue=task_queue&username=guest&routingKey=test_task&password=guest" +
                        "&autoAck=true&durable=true&exchangeType=direct&autoDelete=false&exchangePattern=InOut")
        .process(new Processor() {
                            @Override
                            public void process(Exchange exchange) throws Exception {
                                exchange.setOut(exchange.getIn());
                                Message m = exchange.getOut();
                                org.apache.camel.TypeConverter tc = exchange.getContext().getTypeConverter();
                                String strValue = tc.convertTo(String.class, m.getBody());
                                System.out.println("[[task_queue -- out_queue]]: "  + strValue);
                            }
                        })
                       .to("rabbitmq://localhost:5672/test_op?queue=out_queue&routingKey=test_out&username=guest&password=guest" +
                            "&autoAck=true&durable=true&exchangeType=direct&autoDelete=false&exchangePattern=InOut");
            }
我的程序中只有这两条路线,没有其他路线。现在,当我运行它时,我得到以下输出:

[[task_queue -- out_queue]]: This is a test message: 
[[task_queue -- out_queue]]: This is a test message: 
[[task_queue -- out_queue]]: This is a test message: 
[[task_queue -- out_queue]]: This is a test message: 
[[task_queue -- out_queue]]: This is a test message: 
.
.
(continuous stream till I kill program)
我上面显示的输出不是预期的输出。它不应该多次打印输出消息,但应该只打印一次。这意味着一条消息正在被一次又一次地处理(并传输到
输出队列


有人能说出原因吗?非常感谢您的帮助。

此线程解决了我的问题:

没有任何明显的问题。您是否尝试过用seda队列替换RabbitMQ队列,以便查看问题是否与Camel到RabbitMQ有关?它与RabbitMQ有关。因为我在其他组件上试过,但这个问题没有复制。