本文整理汇总了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;
}
示例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);
}
}
示例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);
}
示例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);
}