Apache camel 将确认消息聚合到camel中的rabbitmq
我正在camel中使用Apache camel 将确认消息聚合到camel中的rabbitmq,apache-camel,rabbitmq,Apache Camel,Rabbitmq,我正在camel中使用rabbitmq组件。我有以下路线: public void configure() throws Exception { from("rabbitmq://localhost:5672/test_op?queue=out_queue&routingKey=test_out&username=guest&password=guest" + "&au
rabbitmq
组件。我有以下路线:
public void configure() throws Exception {
from("rabbitmq://localhost:5672/test_op?queue=out_queue&routingKey=test_out&username=guest&password=guest" +
"&autoAck=false&durable=true&exchangeType=direct&autoDelete=false&exchangePattern=InOut")
.aggregate(constant(true), new ArrayListAggregationStrategy())
.completionSize(2000).completionTimeout(60000).eagerCheckCompletion()
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Message m = exchange.getIn();
org.apache.camel.TypeConverter tc = exchange.getContext().getTypeConverter();
String strValue = tc.convertTo(String.class, m.getBody());
System.out.println("[[out_queue]]: " + strValue);
}
});
}
问题是,aggregate
的使用甚至在调用process()
之前就向rabbitmq确认消息。我只想在process()
执行成功时确认消息,而不是在调用aggregate
时确认消息。我怎样才能做到这一点
仅供参考:如果没有aggregate
,该路线将按预期运行。这意味着只有在成功执行process()
时,它才会确认消息