return wrapChannel(routeContext, processor);
}
protected Processor wrapChannel(RouteContext routeContext, Processor processor) throws Exception {
// put a channel inbetween this and each output to control the route flow logic
Channel channel = createChannel(routeContext);
channel.setNextProcessor(processor);
// add interceptor strategies to the channel must be in this order: camel context, route context, local
addInterceptStrategies(routeContext, channel, routeContext.getCamelContext().getInterceptStrategies());
addInterceptStrategies(routeContext, channel, routeContext.getInterceptStrategies());
addInterceptStrategies(routeContext, channel, this.getInterceptStrategies());
// init the channel
channel.initChannel(this, routeContext);
// set the error handler, must be done after init as we can set the error handler as first in the chain
if (this instanceof TryDefinition || this instanceof CatchDefinition || this instanceof FinallyDefinition) {
// do not use error handler for try .. catch .. finally blocks as it will handle errors itself
return channel;
} else {
// regular definition so add the error handler
Processor output = channel.getOutput();
Processor errorHandler = getErrorHandlerBuilder().createErrorHandler(routeContext, output);
channel.setErrorHandler(errorHandler);
return channel;
}
}