我正在使用多播将传入消息发送到两个不同的端点并汇总响应。即使端点响应之一超时,我也希望获得响应。
我可以使用“超时”或completionTimeout哪种方法?
我正在使用并行处理来处理消息。

 .multicast()
 .to("direct:A","direct:B")
 .parallelProcessing()
 //.timeout(1000L)
 .aggregationStrategy(new MyAggregationStrategy())
 //.completionTimeout(2000L)
 .end()


在这种情况下,如何使用TimeoutAwareAggregationStrategy。

public class MyAggregationStrategy implements TimeoutAwareAggregationStrategy {
@Override
public Exchange aggregate(Exchange newExchange, Exchange originalExchange) {
    if(newExchange==null){
        return originalExchange;
    }
    else {
        ExchangeHelper.copyResults(originalExchange, newExchange);
        return originalExchange;
    }
}}

最佳答案

使用timeout,并查看此单元测试的示例:https://github.com/apache/camel/blob/master/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelTimeoutAwareTest.java

10-06 11:10