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 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.

  • 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 class MulticastProcessor
      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 class MulticastProcessor
      Throws:
      Exception
    • doInit

      protected void doInit() throws Exception
      Overrides:
      doInit in class MulticastProcessor
      Throws:
      Exception
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class MulticastProcessor
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class MulticastProcessor
      Throws:
      Exception
    • doShutdown

      protected void doShutdown() throws Exception
      Overrides:
      doShutdown in class MulticastProcessor
      Throws:
      Exception
    • getTraceLabel

      public String getTraceLabel()
      Specified by:
      getTraceLabel in interface org.apache.camel.Traceable
      Overrides:
      getTraceLabel in class MulticastProcessor