当前位置: 首页>>代码示例>>Java>>正文


Java TimeoutAwareAggregationStrategy类代码示例

本文整理汇总了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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:31,代码来源:MulticastProcessor.java


注:本文中的org.apache.camel.processor.aggregate.TimeoutAwareAggregationStrategy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。