Package org.apache.camel.processor
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 ClassesModifier and TypeClassDescriptionprotected static interfaceThe iterator to be used for retrieving the next routing slip(s) to be used. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected final org.apache.camel.CamelContextprotected org.apache.camel.AsyncProcessorprotected org.apache.camel.Expressionprotected Stringprotected Stringprotected booleanprotected org.apache.camel.spi.ProducerCacheprotected Stringprotected StringFields 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
ConstructorsConstructorDescriptionRoutingSlip(org.apache.camel.CamelContext camelContext) RoutingSlip(org.apache.camel.CamelContext camelContext, org.apache.camel.Expression expression, String uriDelimiter) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.camel.AsyncProcessorcreateErrorHandler(org.apache.camel.Route route, org.apache.camel.Exchange exchange, org.apache.camel.AsyncProcessor processor, org.apache.camel.Endpoint endpoint) protected RoutingSlip.RoutingSlipIteratorcreateRoutingSlipIterator(org.apache.camel.Exchange exchange, org.apache.camel.Expression expression) Creates the route slip iterator to be used.protected voidprotected voiddoStart()protected voiddoStop()intorg.apache.camel.spi.EndpointUtilizationStatisticsorg.apache.camel.AsyncProcessorprotected static org.apache.camel.EndpointgetExistingEndpoint(org.apache.camel.Exchange exchange, Object recipient) org.apache.camel.ExpressiongetId()booleanorg.apache.camel.AsyncProcessorCreates the embedded processor to use when wrapping this routing slip in an error handler.protected org.apache.camel.ExchangeprepareExchangeForRoutingSlip(org.apache.camel.Exchange current, org.apache.camel.Endpoint endpoint) protected static ObjectprepareRecipient(org.apache.camel.Exchange exchange, Object recipient) booleanprocess(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback) protected booleanprocessExchange(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.EndpointresolveEndpoint(org.apache.camel.Exchange exchange, Object recipient, boolean prototype) voidsetCacheSize(int cacheSize) voidsetDelimiter(String delimiter) voidsetErrorHandler(org.apache.camel.AsyncProcessor errorHandler) voidvoidsetIgnoreInvalidEndpoints(boolean ignoreInvalidEndpoints) voidsetRouteId(String routeId) toString()Methods inherited from class org.apache.camel.support.AsyncProcessorSupport
process, processAsyncMethods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.camel.spi.IdAware
setGeneratedIdMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Field Details
-
id
-
routeId
-
producerCache
protected org.apache.camel.spi.ProducerCache producerCache -
cacheSize
protected int cacheSize -
ignoreInvalidEndpoints
protected boolean ignoreInvalidEndpoints -
header
-
expression
protected org.apache.camel.Expression expression -
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
- Specified by:
getIdin interfaceorg.apache.camel.spi.HasId
-
setId
- Specified by:
setIdin interfaceorg.apache.camel.spi.IdAware
-
getRouteId
- Specified by:
getRouteIdin interfaceorg.apache.camel.spi.RouteIdAware
-
setRouteId
- Specified by:
setRouteIdin interfaceorg.apache.camel.spi.RouteIdAware
-
getExpression
public org.apache.camel.Expression getExpression() -
getUriDelimiter
-
setDelimiter
-
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
-
getTraceLabel
- Specified by:
getTraceLabelin interfaceorg.apache.camel.Traceable
-
process
public boolean process(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback) - Specified by:
processin interfaceorg.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 exchangeexpression- 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
- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStop
- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doShutdown
- Overrides:
doShutdownin classorg.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.
-