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, processorExchangeFactoryFields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING -
Constructor Summary
ConstructorsConstructorDescriptionRecipientListProcessor(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, int cacheSize) -
Method Summary
Modifier and TypeMethodDescriptionprotected ProcessorExchangePaircreateProcessorExchangePair(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 voiddoBuild()protected voiddoInit()protected voidprotected voiddoStart()protected voiddoStop()intMaximum cache size used for reusing processorsprotected static org.apache.camel.EndpointgetExistingEndpoint(org.apache.camel.Exchange exchange, Object recipient) booleanprotected static ObjectprepareRecipient(org.apache.camel.Exchange exchange, Object recipient) protected static org.apache.camel.EndpointresolveEndpoint(org.apache.camel.Exchange exchange, Object recipient, boolean prototype) protected org.apache.camel.ExchangePatternresolveExchangePattern(Object recipient) voidsetCacheSize(int cacheSize) voidsetIgnoreInvalidEndpoints(boolean ignoreInvalidEndpoints) protected static voidsetToEndpoint(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, schedule, setAggregateExecutorService, setAggregationStrategyOnExchange, setErrorHandler, setId, setRouteId, setSynchronous, setToEndpoint, toString, updateNewExchange, wrapInErrorHandlerMethods inherited from class org.apache.camel.support.AsyncProcessorSupport
process, processAsyncMethods inherited from class org.apache.camel.support.service.BaseService
build, doFail, 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
-
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, int cacheSize)
-
-
Method Details
-
getCacheSize
public int getCacheSize()Description copied from class:MulticastProcessorMaximum cache size used for reusing processors- Overrides:
getCacheSizein classMulticastProcessor
-
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:
createProcessorExchangePairsin 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:
doBuildin classMulticastProcessor- Throws:
Exception
-
doInit
- Overrides:
doInitin classMulticastProcessor- Throws:
Exception
-
doStart
- Overrides:
doStartin classMulticastProcessor- Throws:
Exception
-
doStop
- Overrides:
doStopin classMulticastProcessor- Throws:
Exception
-
doShutdown
- Overrides:
doShutdownin classMulticastProcessor- Throws:
Exception
-
getTraceLabel
- Specified by:
getTraceLabelin interfaceorg.apache.camel.Traceable- Overrides:
getTraceLabelin classMulticastProcessor
-