Class RoutingSlip

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.AsyncProcessorSupport
org.apache.camel.processor.RoutingSlip
All Implemented Interfaces:
AutoCloseable, org.apache.camel.AsyncProcessor, org.apache.camel.Processor, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.HasId, org.apache.camel.spi.IdAware, org.apache.camel.spi.RouteIdAware, org.apache.camel.StatefulService, org.apache.camel.SuspendableService, org.apache.camel.Traceable
Direct Known Subclasses:
DynamicRouter

public class RoutingSlip extends org.apache.camel.support.AsyncProcessorSupport implements org.apache.camel.Traceable, org.apache.camel.spi.IdAware, org.apache.camel.spi.RouteIdAware
Implements a Routing Slip pattern where the list of actual endpoints to send a message exchange to are dependent on the value of a message header.

This implementation mirrors the logic from the Pipeline in the async variation as the failover load balancer is a specialized pipeline. So the trick is to keep doing the same as the pipeline to ensure it works the same and the async routing engine is flawless.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static interface 
    The iterator to be used for retrieving the next routing slip(s) to be used.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
     
    protected final org.apache.camel.CamelContext
     
    protected org.apache.camel.AsyncProcessor
     
    protected org.apache.camel.Expression
     
    protected String
     
    protected String
     
    protected boolean
     
    protected org.apache.camel.spi.ProducerCache
     
    protected String
     
    protected String
     

    Fields inherited from class org.apache.camel.support.service.BaseService

    BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
  • Constructor Summary

    Constructors
    Constructor
    Description
    RoutingSlip(org.apache.camel.CamelContext camelContext)
     
    RoutingSlip(org.apache.camel.CamelContext camelContext, org.apache.camel.Expression expression, String uriDelimiter)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.apache.camel.AsyncProcessor
    createErrorHandler(org.apache.camel.Route route, org.apache.camel.Exchange exchange, org.apache.camel.AsyncProcessor processor, org.apache.camel.Endpoint endpoint)
     
    createRoutingSlipIterator(org.apache.camel.Exchange exchange, org.apache.camel.Expression expression)
    Creates the route slip iterator to be used.
    protected void
     
    protected void
     
    protected void
     
    int
     
    org.apache.camel.spi.EndpointUtilizationStatistics
     
    org.apache.camel.AsyncProcessor
     
    protected static org.apache.camel.Endpoint
    getExistingEndpoint(org.apache.camel.Exchange exchange, Object recipient)
     
    org.apache.camel.Expression
     
     
     
     
     
    boolean
     
    org.apache.camel.AsyncProcessor
    Creates the embedded processor to use when wrapping this routing slip in an error handler.
    protected org.apache.camel.Exchange
    prepareExchangeForRoutingSlip(org.apache.camel.Exchange current, org.apache.camel.Endpoint endpoint)
     
    protected static Object
    prepareRecipient(org.apache.camel.Exchange exchange, Object recipient)
     
    boolean
    process(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback)
     
    protected boolean
    processExchange(org.apache.camel.Endpoint endpoint, org.apache.camel.Exchange exchange, org.apache.camel.Exchange original, org.apache.camel.AsyncCallback originalCallback, RoutingSlip.RoutingSlipIterator iter, boolean prototype)
     
    protected org.apache.camel.Endpoint
    resolveEndpoint(org.apache.camel.Exchange exchange, Object recipient, boolean prototype)
     
    void
    setCacheSize(int cacheSize)
     
    void
    setDelimiter(String delimiter)
     
    void
    setErrorHandler(org.apache.camel.AsyncProcessor errorHandler)
     
    void
     
    void
    setIgnoreInvalidEndpoints(boolean ignoreInvalidEndpoints)
     
    void
    setRouteId(String routeId)
     
     

    Methods inherited from class org.apache.camel.support.AsyncProcessorSupport

    process, processAsync

    Methods inherited from class org.apache.camel.support.service.BaseService

    build, doBuild, doFail, doInit, doLifecycleChange, doResume, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.camel.spi.IdAware

    setGeneratedId

    Methods inherited from interface org.apache.camel.Service

    build, close, init, start, stop

    Methods inherited from interface org.apache.camel.ShutdownableService

    shutdown

    Methods inherited from interface org.apache.camel.StatefulService

    getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending

    Methods inherited from interface org.apache.camel.SuspendableService

    isSuspended, resume, suspend
  • Field Details

    • id

      protected String id
    • routeId

      protected String routeId
    • producerCache

      protected org.apache.camel.spi.ProducerCache producerCache
    • cacheSize

      protected int cacheSize
    • ignoreInvalidEndpoints

      protected boolean ignoreInvalidEndpoints
    • expression

      protected org.apache.camel.Expression expression
    • uriDelimiter

      protected String uriDelimiter
    • camelContext

      protected final org.apache.camel.CamelContext camelContext
    • errorHandler

      protected org.apache.camel.AsyncProcessor errorHandler
  • Constructor Details

    • RoutingSlip

      public RoutingSlip(org.apache.camel.CamelContext camelContext)
    • RoutingSlip

      public RoutingSlip(org.apache.camel.CamelContext camelContext, org.apache.camel.Expression expression, String uriDelimiter)
  • Method Details

    • getId

      public String getId()
      Specified by:
      getId in interface org.apache.camel.spi.HasId
    • setId

      public void setId(String id)
      Specified by:
      setId in interface org.apache.camel.spi.IdAware
    • getRouteId

      public String getRouteId()
      Specified by:
      getRouteId in interface org.apache.camel.spi.RouteIdAware
    • setRouteId

      public void setRouteId(String routeId)
      Specified by:
      setRouteId in interface org.apache.camel.spi.RouteIdAware
    • getExpression

      public org.apache.camel.Expression getExpression()
    • getUriDelimiter

      public String getUriDelimiter()
    • setDelimiter

      public void setDelimiter(String delimiter)
    • isIgnoreInvalidEndpoints

      public boolean isIgnoreInvalidEndpoints()
    • setIgnoreInvalidEndpoints

      public void setIgnoreInvalidEndpoints(boolean ignoreInvalidEndpoints)
    • getCacheSize

      public int getCacheSize()
    • setCacheSize

      public void setCacheSize(int cacheSize)
    • getErrorHandler

      public org.apache.camel.AsyncProcessor getErrorHandler()
    • setErrorHandler

      public void setErrorHandler(org.apache.camel.AsyncProcessor errorHandler)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getTraceLabel

      public String getTraceLabel()
      Specified by:
      getTraceLabel in interface org.apache.camel.Traceable
    • process

      public boolean process(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback)
      Specified by:
      process in interface org.apache.camel.AsyncProcessor
    • createRoutingSlipIterator

      protected RoutingSlip.RoutingSlipIterator createRoutingSlipIterator(org.apache.camel.Exchange exchange, org.apache.camel.Expression expression) throws Exception
      Creates the route slip iterator to be used.
      Parameters:
      exchange - the exchange
      expression - the expression
      Returns:
      the iterator, should never be null
      Throws:
      Exception
    • prepareRecipient

      protected static Object prepareRecipient(org.apache.camel.Exchange exchange, Object recipient) throws org.apache.camel.NoTypeConversionAvailableException
      Throws:
      org.apache.camel.NoTypeConversionAvailableException
    • getExistingEndpoint

      protected static org.apache.camel.Endpoint getExistingEndpoint(org.apache.camel.Exchange exchange, Object recipient)
    • resolveEndpoint

      protected org.apache.camel.Endpoint resolveEndpoint(org.apache.camel.Exchange exchange, Object recipient, boolean prototype) throws Exception
      Throws:
      Exception
    • prepareExchangeForRoutingSlip

      protected org.apache.camel.Exchange prepareExchangeForRoutingSlip(org.apache.camel.Exchange current, org.apache.camel.Endpoint endpoint)
    • createErrorHandler

      protected org.apache.camel.AsyncProcessor createErrorHandler(org.apache.camel.Route route, org.apache.camel.Exchange exchange, org.apache.camel.AsyncProcessor processor, org.apache.camel.Endpoint endpoint)
    • processExchange

      protected boolean processExchange(org.apache.camel.Endpoint endpoint, org.apache.camel.Exchange exchange, org.apache.camel.Exchange original, org.apache.camel.AsyncCallback originalCallback, RoutingSlip.RoutingSlipIterator iter, boolean prototype)
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • doShutdown

      protected void doShutdown() throws Exception
      Overrides:
      doShutdown in class org.apache.camel.support.service.BaseService
      Throws:
      Exception
    • getEndpointUtilizationStatistics

      public org.apache.camel.spi.EndpointUtilizationStatistics getEndpointUtilizationStatistics()
    • newRoutingSlipProcessorForErrorHandler

      public org.apache.camel.AsyncProcessor newRoutingSlipProcessorForErrorHandler()
      Creates the embedded processor to use when wrapping this routing slip in an error handler.