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


Java ExchangeHelper.isFailureHandled方法代码示例

本文整理汇总了Java中org.apache.camel.util.ExchangeHelper.isFailureHandled方法的典型用法代码示例。如果您正苦于以下问题:Java ExchangeHelper.isFailureHandled方法的具体用法?Java ExchangeHelper.isFailureHandled怎么用?Java ExchangeHelper.isFailureHandled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.camel.util.ExchangeHelper的用法示例。


在下文中一共展示了ExchangeHelper.isFailureHandled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isDone

import org.apache.camel.util.ExchangeHelper; //导入方法依赖的package包/类
/**
 * Strategy to determine if the exchange is done so we can continue
 */
protected boolean isDone(Exchange exchange) {
    boolean answer = isCancelledOrInterrupted(exchange);

    // only done if the exchange hasn't failed
    // and it has not been handled by the failure processor
    // or we are exhausted
    if (!answer) {
        answer = exchange.getException() == null
            || ExchangeHelper.isFailureHandled(exchange)
            || ExchangeHelper.isRedeliveryExhausted(exchange);
    }

    log.trace("Is exchangeId: {} done? {}", exchange.getExchangeId(), answer);
    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:RedeliveryErrorHandler.java

示例2: onComplete

import org.apache.camel.util.ExchangeHelper; //导入方法依赖的package包/类
public void onComplete(Exchange exchange) {
    if (ExchangeHelper.isFailureHandled(exchange)) {
        // the exchange did not process successfully but was failure handled by the dead letter channel
        // and thus moved to the dead letter queue. We should thus not consider it as complete.
        onFailedMessage(exchange, messageId);
    } else {
        onCompletedMessage(exchange, messageId);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:IdempotentOnCompletion.java

示例3: completedExchange

import org.apache.camel.util.ExchangeHelper; //导入方法依赖的package包/类
public synchronized void completedExchange(Exchange exchange, long time) {
    increment();
    exchangesCompleted.increment();
    exchangesInflight.decrement();

    if (ExchangeHelper.isFailureHandled(exchange)) {
        failuresHandled.increment();
    }
    Boolean externalRedelivered = exchange.isExternalRedelivered();
    if (externalRedelivered != null && externalRedelivered) {
        externalRedeliveries.increment();
    }

    minProcessingTime.updateValue(time);
    maxProcessingTime.updateValue(time);
    totalProcessingTime.updateValue(time);
    lastProcessingTime.updateValue(time);
    deltaProcessingTime.updateValue(time);

    long now = new Date().getTime();
    if (firstExchangeCompletedTimestamp.getUpdateCount() == 0) {
        firstExchangeCompletedTimestamp.updateValue(now);
    }

    lastExchangeCompletedTimestamp.updateValue(now);
    if (firstExchangeCompletedExchangeId == null) {
        firstExchangeCompletedExchangeId = exchange.getExchangeId();
    }
    lastExchangeCompletedExchangeId = exchange.getExchangeId();

    // update mean
    long count = exchangesCompleted.getValue();
    long mean = count > 0 ? totalProcessingTime.getValue() / count : 0;
    meanProcessingTime.updateValue(mean);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:36,代码来源:ManagedPerformanceCounter.java

示例4: handleException

import org.apache.camel.util.ExchangeHelper; //导入方法依赖的package包/类
protected void handleException(Exchange exchange, RedeliveryData data, boolean isDeadLetterChannel) {
    Exception e = exchange.getException();

    // store the original caused exception in a property, so we can restore it later
    exchange.setProperty(Exchange.EXCEPTION_CAUGHT, e);

    // find the error handler to use (if any)
    OnExceptionDefinition exceptionPolicy = getExceptionPolicy(exchange, e);
    if (exceptionPolicy != null) {
        data.currentRedeliveryPolicy = exceptionPolicy.createRedeliveryPolicy(exchange.getContext(), data.currentRedeliveryPolicy);
        data.handledPredicate = exceptionPolicy.getHandledPolicy();
        data.continuedPredicate = exceptionPolicy.getContinuedPolicy();
        data.retryWhilePredicate = exceptionPolicy.getRetryWhilePolicy();
        data.useOriginalInMessage = exceptionPolicy.getUseOriginalMessagePolicy() != null && exceptionPolicy.getUseOriginalMessagePolicy();

        // route specific failure handler?
        Processor processor = null;
        UnitOfWork uow = exchange.getUnitOfWork();
        if (uow != null && uow.getRouteContext() != null) {
            String routeId = uow.getRouteContext().getRoute().getId();
            processor = exceptionPolicy.getErrorHandler(routeId);
        } else if (!exceptionPolicy.getErrorHandlers().isEmpty()) {
            // note this should really not happen, but we have this code as a fail safe
            // to be backwards compatible with the old behavior
            log.warn("Cannot determine current route from Exchange with id: {}, will fallback and use first error handler.", exchange.getExchangeId());
            processor = exceptionPolicy.getErrorHandlers().iterator().next();
        }
        if (processor != null) {
            data.failureProcessor = processor;
        }

        // route specific on redelivery?
        processor = exceptionPolicy.getOnRedelivery();
        if (processor != null) {
            data.onRedeliveryProcessor = processor;
        }
        // route specific on exception occurred?
        processor = exceptionPolicy.getOnExceptionOccurred();
        if (processor != null) {
            data.onExceptionProcessor = processor;
        }
    }

    // only log if not failure handled or not an exhausted unit of work
    if (!ExchangeHelper.isFailureHandled(exchange) && !ExchangeHelper.isUnitOfWorkExhausted(exchange)) {
        String msg = "Failed delivery for " + ExchangeHelper.logIds(exchange)
                + ". On delivery attempt: " + data.redeliveryCounter + " caught: " + e;
        logFailedDelivery(true, false, false, false, isDeadLetterChannel, exchange, msg, data, e);
    }

    data.redeliveryCounter = incrementRedeliveryCounter(exchange, e, data);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:53,代码来源:RedeliveryErrorHandler.java


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