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 thePipeline
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
RoutingSlip.RoutingSlipIterator
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
cacheSize
protected org.apache.camel.CamelContext
camelContext
protected org.apache.camel.AsyncProcessor
errorHandler
protected org.apache.camel.Expression
expression
protected String
header
protected String
id
protected boolean
ignoreInvalidEndpoints
protected org.apache.camel.spi.ProducerCache
producerCache
protected String
routeId
protected String
uriDelimiter
-
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
All Methods Static Methods Instance Methods Concrete Methods 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)
protected RoutingSlip.RoutingSlipIterator
createRoutingSlipIterator(org.apache.camel.Exchange exchange, org.apache.camel.Expression expression)
Creates the route slip iterator to be used.protected void
doShutdown()
protected void
doStart()
protected void
doStop()
int
getCacheSize()
org.apache.camel.spi.EndpointUtilizationStatistics
getEndpointUtilizationStatistics()
org.apache.camel.AsyncProcessor
getErrorHandler()
protected static org.apache.camel.Endpoint
getExistingEndpoint(org.apache.camel.Exchange exchange, Object recipient)
org.apache.camel.Expression
getExpression()
String
getId()
String
getRouteId()
String
getTraceLabel()
String
getUriDelimiter()
boolean
isIgnoreInvalidEndpoints()
org.apache.camel.AsyncProcessor
newRoutingSlipProcessorForErrorHandler()
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
setId(String id)
void
setIgnoreInvalidEndpoints(boolean ignoreInvalidEndpoints)
void
setRouteId(String routeId)
String
toString()
-
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
-
-
-
-
Field Detail
-
id
protected String id
-
routeId
protected String routeId
-
producerCache
protected org.apache.camel.spi.ProducerCache producerCache
-
cacheSize
protected int cacheSize
-
ignoreInvalidEndpoints
protected boolean ignoreInvalidEndpoints
-
header
protected String header
-
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 Detail
-
RoutingSlip
public RoutingSlip(org.apache.camel.CamelContext camelContext)
-
RoutingSlip
public RoutingSlip(org.apache.camel.CamelContext camelContext, org.apache.camel.Expression expression, String uriDelimiter)
-
-
Method Detail
-
getId
public String getId()
- Specified by:
getId
in interfaceorg.apache.camel.spi.HasId
-
setId
public void setId(String id)
- Specified by:
setId
in interfaceorg.apache.camel.spi.IdAware
-
getRouteId
public String getRouteId()
- Specified by:
getRouteId
in interfaceorg.apache.camel.spi.RouteIdAware
-
setRouteId
public void setRouteId(String routeId)
- Specified by:
setRouteId
in interfaceorg.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)
-
getTraceLabel
public String getTraceLabel()
- Specified by:
getTraceLabel
in interfaceorg.apache.camel.Traceable
-
process
public boolean process(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback)
- Specified by:
process
in 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
protected void doStart() throws Exception
- Overrides:
doStart
in classorg.apache.camel.support.AsyncProcessorSupport
- Throws:
Exception
-
doStop
protected void doStop() throws Exception
- Overrides:
doStop
in classorg.apache.camel.support.AsyncProcessorSupport
- Throws:
Exception
-
doShutdown
protected void doShutdown() throws Exception
- Overrides:
doShutdown
in 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.
-
-