本文整理汇总了Java中org.apache.camel.processor.aggregate.TimeoutAwareAggregationStrategy类的典型用法代码示例。如果您正苦于以下问题:Java TimeoutAwareAggregationStrategy类的具体用法?Java TimeoutAwareAggregationStrategy怎么用?Java TimeoutAwareAggregationStrategy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TimeoutAwareAggregationStrategy类属于org.apache.camel.processor.aggregate包,在下文中一共展示了TimeoutAwareAggregationStrategy类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.apache.camel.processor.aggregate.TimeoutAwareAggregationStrategy; //导入依赖的package包/类
@Override
public void run() {
AggregationStrategy strategy = getAggregationStrategy(null);
if (strategy instanceof DelegateAggregationStrategy) {
strategy = ((DelegateAggregationStrategy) strategy).getDelegate();
}
if (strategy instanceof TimeoutAwareAggregationStrategy) {
// notify the strategy we timed out
Exchange oldExchange = result.get();
if (oldExchange == null) {
// if they all timed out the result may not have been set yet, so use the original exchange
oldExchange = original;
}
((TimeoutAwareAggregationStrategy) strategy).timeout(oldExchange, aggregated.intValue(), total.intValue(), timeout);
} else {
// log a WARN we timed out since it will not be aggregated and the Exchange will be lost
LOG.warn("Parallel processing timed out after {} millis for number {}. This task will be cancelled and will not be aggregated.", timeout, aggregated.intValue());
}
LOG.debug("Timeout occurred after {} millis for number {} task.", timeout, aggregated.intValue());
timedOut.set(true);
// mark that index as timed out, which allows us to try to retrieve
// any already completed tasks in the next loop
if (completion instanceof SubmitOrderedCompletionService) {
((SubmitOrderedCompletionService<?>) completion).timeoutTask();
}
// we timed out so increment the counter
aggregated.incrementAndGet();
}