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
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 specialized
MulticastProcessor
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
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
ConstructorDescriptionRecipientListProcessor
(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
Modifier and TypeMethodDescriptionprotected 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
protected void
doStart()
protected void
doStop()
int
protected static org.apache.camel.Endpoint
getExistingEndpoint
(org.apache.camel.Exchange exchange, Object recipient) boolean
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, doProcess, getAggregateExecutorService, getAggregationStrategy, getAggregationStrategy, getCamelContext, getErrorHandler, getExchangeIndex, getId, getProcessors, getRouteId, getTimeout, hasNext, isParallelAggregate, isParallelProcessing, isShareUnitOfWork, isStopOnException, isStreaming, isSynchronous, next, prepareSharedUnitOfWork, process, removeAggregationStrategyFromExchange, schedule, schedule, setAggregateExecutorService, setAggregationStrategyOnExchange, setErrorHandler, setId, setRouteId, setSynchronous, setToEndpoint, toString, updateNewExchange, wrapInErrorHandler
Methods inherited from class org.apache.camel.support.AsyncProcessorSupport
process, processAsync
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
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
-
Constructor Details
-
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 Details
-
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
-
setToEndpoint
protected static void setToEndpoint(org.apache.camel.Exchange exchange, org.apache.camel.Endpoint endpoint) -
doBuild
- Overrides:
doBuild
in classMulticastProcessor
- Throws:
Exception
-
doInit
- Overrides:
doInit
in classMulticastProcessor
- Throws:
Exception
-
doStart
- Overrides:
doStart
in classMulticastProcessor
- Throws:
Exception
-
doStop
- Overrides:
doStop
in classMulticastProcessor
- Throws:
Exception
-
doShutdown
- Overrides:
doShutdown
in classMulticastProcessor
- Throws:
Exception
-
getTraceLabel
- Specified by:
getTraceLabel
in interfaceorg.apache.camel.Traceable
- Overrides:
getTraceLabel
in classMulticastProcessor
-