org.apache.camel.processor
Class RecipientListProcessor

java.lang.Object
  extended by org.apache.camel.support.ServiceSupport
      extended by org.apache.camel.processor.MulticastProcessor
          extended by org.apache.camel.processor.RecipientListProcessor
All Implemented Interfaces:
AsyncProcessor, Navigate<Processor>, Processor, Service, ShutdownableService, StatefulService, SuspendableService, 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 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.

Version:

Field Summary
 
Fields inherited from class org.apache.camel.processor.MulticastProcessor
onPrepare
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Constructor Summary
RecipientListProcessor(CamelContext camelContext, ProducerCache producerCache, Iterator<Object> iter)
           
RecipientListProcessor(CamelContext camelContext, ProducerCache producerCache, Iterator<Object> iter, AggregationStrategy aggregationStrategy)
           
RecipientListProcessor(CamelContext camelContext, ProducerCache producerCache, Iterator<Object> iter, AggregationStrategy aggregationStrategy, boolean parallelProcessing, ExecutorService executorService, boolean shutdownExecutorService, boolean streaming, boolean stopOnException, long timeout, Processor onPrepare, boolean shareUnitOfWork)
           
 
Method Summary
protected  ProcessorExchangePair createProcessorExchangePair(int index, Endpoint endpoint, Producer producer, Exchange exchange)
          This logic is similar to MulticastProcessor but we have to return a RecipientProcessorExchangePair instead
protected  Iterable<ProcessorExchangePair> createProcessorExchangePairs(Exchange exchange)
           
protected  void doShutdown()
          Implementations override this method to perform customized shutdown.
protected  void doStart()
          Implementations override this method to support customized start/stop.
protected  void doStop()
          Implementations override this method to support customized start/stop.
 String getTraceLabel()
          Gets the trace label used for logging when tracing is enabled.
 boolean isIgnoreInvalidEndpoints()
           
protected static Endpoint resolveEndpoint(Exchange exchange, Object recipient)
           
 void setIgnoreInvalidEndpoints(boolean ignoreInvalidEndpoints)
           
 String toString()
           
 
Methods inherited from class org.apache.camel.processor.MulticastProcessor
createAggregateExecutorService, createErrorHandler, createProcessorExchangePair, createUnitOfWorkProcessor, doAggregate, doDone, doProcessParallel, doProcessSequential, getAggregationStrategy, getAggregationStrategy, getCamelContext, getExchangeIndex, getProcessors, getTimeout, hasNext, isParallelProcessing, isShareUnitOfWork, isStopOnException, isStreaming, next, prepareSharedUnitOfWork, process, process, removeAggregationStrategyFromExchange, setAggregationStrategyOnExchange, setToEndpoint, updateNewExchange
 
Methods inherited from class org.apache.camel.support.ServiceSupport
doResume, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, 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(CamelContext camelContext,
                              ProducerCache producerCache,
                              Iterator<Object> iter)

RecipientListProcessor

public RecipientListProcessor(CamelContext camelContext,
                              ProducerCache producerCache,
                              Iterator<Object> iter,
                              AggregationStrategy aggregationStrategy)

RecipientListProcessor

public RecipientListProcessor(CamelContext camelContext,
                              ProducerCache producerCache,
                              Iterator<Object> iter,
                              AggregationStrategy aggregationStrategy,
                              boolean parallelProcessing,
                              ExecutorService executorService,
                              boolean shutdownExecutorService,
                              boolean streaming,
                              boolean stopOnException,
                              long timeout,
                              Processor onPrepare,
                              boolean shareUnitOfWork)
Method Detail

isIgnoreInvalidEndpoints

public boolean isIgnoreInvalidEndpoints()

setIgnoreInvalidEndpoints

public void setIgnoreInvalidEndpoints(boolean ignoreInvalidEndpoints)

createProcessorExchangePairs

protected Iterable<ProcessorExchangePair> createProcessorExchangePairs(Exchange exchange)
                                                                throws Exception
Overrides:
createProcessorExchangePairs in class MulticastProcessor
Throws:
Exception

createProcessorExchangePair

protected ProcessorExchangePair createProcessorExchangePair(int index,
                                                            Endpoint endpoint,
                                                            Producer producer,
                                                            Exchange exchange)
This logic is similar to MulticastProcessor but we have to return a RecipientProcessorExchangePair instead


resolveEndpoint

protected static Endpoint resolveEndpoint(Exchange exchange,
                                          Object recipient)

doStart

protected void doStart()
                throws Exception
Description copied from class: ServiceSupport
Implementations override this method to support customized start/stop.

Important: See ServiceSupport.doStop() for more details.

Overrides:
doStart in class MulticastProcessor
Throws:
Exception
See Also:
ServiceSupport.doStop()

doStop

protected void doStop()
               throws Exception
Description copied from class: ServiceSupport
Implementations override this method to support customized start/stop.

Important: Camel will invoke this ServiceSupport.doStop() method when the service is being stopped. This method will also be invoked if the service is still in uninitialized state (eg has not been started). The method is always called to allow the service to do custom logic when the service is being stopped, such as when CamelContext is shutting down.

Overrides:
doStop in class MulticastProcessor
Throws:
Exception
See Also:
ServiceSupport.doStart()

doShutdown

protected void doShutdown()
                   throws Exception
Description copied from class: ServiceSupport
Implementations override this method to perform customized shutdown.

Overrides:
doShutdown in class MulticastProcessor
Throws:
Exception

toString

public String toString()
Overrides:
toString in class MulticastProcessor

getTraceLabel

public String getTraceLabel()
Description copied from interface: Traceable
Gets the trace label used for logging when tracing is enabled.

The label should be short and precise.

Specified by:
getTraceLabel in interface Traceable
Overrides:
getTraceLabel in class MulticastProcessor
Returns:
the label


Apache CAMEL