我正在使用多播将传入消息发送到两个不同的端点并聚合响应。即使其中一个端点响应超时,我也想获得响应。 我可以使用哪种方法“超时”或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;
}
}}
最佳答案
使用超时
,并查看此单元测试的示例:https://github.com/apache/camel/blob/master/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelTimeoutAwareTest.java
关于java - completionTimeOut 或 TimeoutAwareAggregationStrategy 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45138276/