Search in sources :

Example 1 with FatalFallbackErrorHandler

use of org.apache.camel.processor.FatalFallbackErrorHandler in project camel by apache.

the class OnExceptionDefinition method addRoutes.

public void addRoutes(RouteContext routeContext, Collection<Route> routes) throws Exception {
    // and therefore is in a better position to decide among context/route scoped OnException at runtime
    if (routeScoped == null) {
        routeScoped = super.getParent() != null;
    }
    setHandledFromExpressionType(routeContext);
    setContinuedFromExpressionType(routeContext);
    setRetryWhileFromExpressionType(routeContext);
    setOnRedeliveryFromRedeliveryRef(routeContext);
    setOnExceptionOccurredFromOnExceptionOccurredRef(routeContext);
    // load exception classes
    if (exceptions != null && !exceptions.isEmpty()) {
        exceptionClasses = createExceptionClasses(routeContext.getCamelContext().getClassResolver());
    }
    // must validate configuration before creating processor
    validateConfiguration();
    if (useOriginalMessagePolicy != null && useOriginalMessagePolicy) {
        // ensure allow original is turned on
        routeContext.setAllowUseOriginalMessage(true);
    }
    // lets attach this on exception to the route error handler
    Processor child = createOutputsProcessor(routeContext);
    if (child != null) {
        // wrap in our special safe fallback error handler if OnException have child output
        Processor errorHandler = new FatalFallbackErrorHandler(child);
        String id = routeContext.getRoute().getId();
        errorHandlers.put(id, errorHandler);
    }
    // lookup the error handler builder
    ErrorHandlerBuilder builder = (ErrorHandlerBuilder) routeContext.getRoute().getErrorHandlerBuilder();
    // and add this as error handlers
    builder.addErrorHandlers(routeContext, this);
}
Also used : ErrorHandlerBuilder(org.apache.camel.builder.ErrorHandlerBuilder) Processor(org.apache.camel.Processor) CatchProcessor(org.apache.camel.processor.CatchProcessor) FatalFallbackErrorHandler(org.apache.camel.processor.FatalFallbackErrorHandler)

Example 2 with FatalFallbackErrorHandler

use of org.apache.camel.processor.FatalFallbackErrorHandler in project camel by apache.

the class DeadLetterChannelBuilder method getFailureProcessor.

// Properties
// -------------------------------------------------------------------------
public Processor getFailureProcessor() {
    if (failureProcessor == null) {
        // wrap in our special safe fallback error handler if sending to dead letter channel fails
        Processor child = new SendProcessor(deadLetter, ExchangePattern.InOnly);
        // force MEP to be InOnly so when sending to DLQ we would not expect a reply if the MEP was InOut
        failureProcessor = new FatalFallbackErrorHandler(child, true);
    }
    return failureProcessor;
}
Also used : Processor(org.apache.camel.Processor) SendProcessor(org.apache.camel.processor.SendProcessor) FatalFallbackErrorHandler(org.apache.camel.processor.FatalFallbackErrorHandler) SendProcessor(org.apache.camel.processor.SendProcessor)

Aggregations

Processor (org.apache.camel.Processor)2 FatalFallbackErrorHandler (org.apache.camel.processor.FatalFallbackErrorHandler)2 ErrorHandlerBuilder (org.apache.camel.builder.ErrorHandlerBuilder)1 CatchProcessor (org.apache.camel.processor.CatchProcessor)1 SendProcessor (org.apache.camel.processor.SendProcessor)1