Interface InterceptStrategy


public interface InterceptStrategy
Strategy that wraps the Processors in a route with interceptors, for cross-cutting concerns such as gathering performance statistics at the processor level.

Camel invokes wrapProcessorInInterceptors(CamelContext, NamedNode, Processor, Processor) for each processor while building a route, giving the strategy the chance to return a wrapping processor (or the original). Registered strategies are applied to every interceptable processor; a processor can opt out by implementing InterceptableProcessor.

It is strongly advised to return an AsyncProcessor as the wrapper, which ensures the interceptor works well with the asynchronous routing engine. You can use

invalid reference
org.apache.camel.support.processor.DelegateAsyncProcessor
to easily return an AsyncProcessor and override AsyncProcessor.process(org.apache.camel.Exchange, org.apache.camel.AsyncCallback) to implement your interceptor logic, then invoke the super method to continue routing.
See Also:
  • Method Details

    • wrapProcessorInInterceptors

      Processor wrapProcessorInInterceptors(CamelContext context, NamedNode definition, Processor target, @Nullable Processor nextTarget) throws Exception
      Give implementor an opportunity to wrap the target processor in a route.

      Important: See the class javadoc for advice on letting interceptor be compatible with the asynchronous routing engine.

      Parameters:
      context - Camel context
      definition - the model this interceptor represents
      target - the processor to be wrapped
      nextTarget - the next processor to be routed to
      Returns:
      processor wrapped with an interceptor or not wrapped.
      Throws:
      Exception - can be thrown