Package org.apache.camel.processor
Class RecipientListProcessor
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.AsyncProcessorSupport
-
- org.apache.camel.processor.MulticastProcessor
-
- org.apache.camel.processor.RecipientListProcessor
-
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.AsyncProcessor
,org.apache.camel.Navigate<org.apache.camel.Processor>
,org.apache.camel.Processor
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.ErrorHandlerAware
,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
public class RecipientListProcessor extends MulticastProcessor
Implements a dynamic Recipient List pattern where the list of actual endpoints to send a message exchange to are dependent on some dynamic expression. This implementation is a specializedMulticastProcessor
which is based on recipient lists. This implementation have to handle the fact the processors is not known at design time but evaluated at runtime from the dynamic recipient list. Therefore this implementation have to at runtime lookup endpoints and create producers which should act as the processors for the multicast processors which runs under the hood. Also this implementation supports the asynchronous routing engine which makes the code more trickier.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.camel.processor.MulticastProcessor
MulticastProcessor.MulticastReactiveTask, MulticastProcessor.MulticastTask, MulticastProcessor.MulticastTransactedTask
-
-
Field Summary
-
Fields inherited from class org.apache.camel.processor.MulticastProcessor
onPrepare, processorExchangeFactory
-
-
Constructor Summary
Constructors Constructor Description RecipientListProcessor(org.apache.camel.CamelContext camelContext, org.apache.camel.Route route, org.apache.camel.Expression expression, String delimiter, org.apache.camel.spi.ProducerCache producerCache, org.apache.camel.AggregationStrategy aggregationStrategy, boolean parallelProcessing, ExecutorService executorService, boolean shutdownExecutorService, boolean streaming, boolean stopOnException, long timeout, org.apache.camel.Processor onPrepare, boolean shareUnitOfWork, boolean parallelAggregate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ProcessorExchangePair
createProcessorExchangePair(int index, org.apache.camel.Endpoint endpoint, org.apache.camel.Producer producer, org.apache.camel.Exchange exchange, org.apache.camel.ExchangePattern pattern, boolean prototypeEndpoint)
This logic is similar to MulticastProcessor but we have to return a RecipientProcessorExchangePair insteadprotected Iterable<ProcessorExchangePair>
createProcessorExchangePairs(org.apache.camel.Exchange exchange)
protected void
doBuild()
protected void
doInit()
protected void
doShutdown()
protected void
doStart()
protected void
doStop()
int
getCacheSize()
protected static org.apache.camel.Endpoint
getExistingEndpoint(org.apache.camel.Exchange exchange, Object recipient)
String
getTraceLabel()
boolean
isIgnoreInvalidEndpoints()
protected static Object
prepareRecipient(org.apache.camel.Exchange exchange, Object recipient)
protected static org.apache.camel.Endpoint
resolveEndpoint(org.apache.camel.Exchange exchange, Object recipient, boolean prototype)
protected org.apache.camel.ExchangePattern
resolveExchangePattern(Object recipient)
void
setCacheSize(int cacheSize)
void
setIgnoreInvalidEndpoints(boolean ignoreInvalidEndpoints)
protected static void
setToEndpoint(org.apache.camel.Exchange exchange, org.apache.camel.Endpoint endpoint)
-
Methods inherited from class org.apache.camel.processor.MulticastProcessor
afterSend, beforeSend, createAggregateExecutorService, createProcessorExchangePair, createUnitOfWorkProcessor, doAggregate, doDone, getAggregateExecutorService, getAggregationStrategy, getAggregationStrategy, getCamelContext, getErrorHandler, getExchangeIndex, getId, getProcessors, getRouteId, getTimeout, hasNext, isParallelAggregate, isParallelProcessing, isShareUnitOfWork, isStopOnException, isStreaming, next, prepareSharedUnitOfWork, process, removeAggregationStrategyFromExchange, schedule, schedule, setAggregateExecutorService, setAggregationStrategyOnExchange, setErrorHandler, setId, setRouteId, setToEndpoint, toString, updateNewExchange, wrapInErrorHandler
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doFail, 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
-
-
-
-
Constructor Detail
-
RecipientListProcessor
public RecipientListProcessor(org.apache.camel.CamelContext camelContext, org.apache.camel.Route route, org.apache.camel.Expression expression, String delimiter, org.apache.camel.spi.ProducerCache producerCache, org.apache.camel.AggregationStrategy aggregationStrategy, boolean parallelProcessing, ExecutorService executorService, boolean shutdownExecutorService, boolean streaming, boolean stopOnException, long timeout, org.apache.camel.Processor onPrepare, boolean shareUnitOfWork, boolean parallelAggregate)
-
-
Method Detail
-
getCacheSize
public int getCacheSize()
-
setCacheSize
public void setCacheSize(int cacheSize)
-
isIgnoreInvalidEndpoints
public boolean isIgnoreInvalidEndpoints()
-
setIgnoreInvalidEndpoints
public void setIgnoreInvalidEndpoints(boolean ignoreInvalidEndpoints)
-
createProcessorExchangePairs
protected Iterable<ProcessorExchangePair> createProcessorExchangePairs(org.apache.camel.Exchange exchange) throws Exception
- Overrides:
createProcessorExchangePairs
in classMulticastProcessor
- Throws:
Exception
-
createProcessorExchangePair
protected ProcessorExchangePair createProcessorExchangePair(int index, org.apache.camel.Endpoint endpoint, org.apache.camel.Producer producer, org.apache.camel.Exchange exchange, org.apache.camel.ExchangePattern pattern, boolean prototypeEndpoint)
This logic is similar to MulticastProcessor but we have to return a RecipientProcessorExchangePair instead
-
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 static org.apache.camel.Endpoint resolveEndpoint(org.apache.camel.Exchange exchange, Object recipient, boolean prototype)
-
resolveExchangePattern
protected org.apache.camel.ExchangePattern resolveExchangePattern(Object recipient)
-
setToEndpoint
protected static void setToEndpoint(org.apache.camel.Exchange exchange, org.apache.camel.Endpoint endpoint)
-
doBuild
protected void doBuild() throws Exception
- Overrides:
doBuild
in classMulticastProcessor
- Throws:
Exception
-
doInit
protected void doInit() throws Exception
- Overrides:
doInit
in classMulticastProcessor
- Throws:
Exception
-
doStart
protected void doStart() throws Exception
- Overrides:
doStart
in classMulticastProcessor
- Throws:
Exception
-
doStop
protected void doStop() throws Exception
- Overrides:
doStop
in classMulticastProcessor
- Throws:
Exception
-
doShutdown
protected void doShutdown() throws Exception
- Overrides:
doShutdown
in classMulticastProcessor
- Throws:
Exception
-
getTraceLabel
public String getTraceLabel()
- Specified by:
getTraceLabel
in interfaceorg.apache.camel.Traceable
- Overrides:
getTraceLabel
in classMulticastProcessor
-
-