Class Resequencer

  • 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.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 Resequencer
    extends org.apache.camel.support.AsyncProcessorSupport
    implements org.apache.camel.Navigate<org.apache.camel.Processor>, org.apache.camel.spi.IdAware, org.apache.camel.spi.RouteIdAware, org.apache.camel.Traceable
    An implementation of the Resequencer which can reorder messages within a batch.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_BATCH_SIZE  
      static long DEFAULT_BATCH_TIMEOUT  
      • 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

      Constructors 
      Constructor Description
      Resequencer​(org.apache.camel.CamelContext camelContext, org.apache.camel.Processor processor, Set<org.apache.camel.Exchange> collection, org.apache.camel.Expression expression)  
      Resequencer​(org.apache.camel.CamelContext camelContext, org.apache.camel.Processor processor, org.apache.camel.Expression expression)  
      Resequencer​(org.apache.camel.CamelContext camelContext, org.apache.camel.Processor processor, org.apache.camel.Expression expression, boolean allowDuplicates, boolean reverse)  
    • Constructor Detail

      • Resequencer

        public Resequencer​(org.apache.camel.CamelContext camelContext,
                           org.apache.camel.Processor processor,
                           org.apache.camel.Expression expression)
      • Resequencer

        public Resequencer​(org.apache.camel.CamelContext camelContext,
                           org.apache.camel.Processor processor,
                           org.apache.camel.Expression expression,
                           boolean allowDuplicates,
                           boolean reverse)
      • Resequencer

        public Resequencer​(org.apache.camel.CamelContext camelContext,
                           org.apache.camel.Processor processor,
                           Set<org.apache.camel.Exchange> collection,
                           org.apache.camel.Expression expression)
    • Method Detail

      • getTraceLabel

        public String getTraceLabel()
        Specified by:
        getTraceLabel in interface org.apache.camel.Traceable
      • getExpression

        public org.apache.camel.Expression getExpression()
      • getExceptionHandler

        public org.apache.camel.spi.ExceptionHandler getExceptionHandler()
      • setExceptionHandler

        public void setExceptionHandler​(org.apache.camel.spi.ExceptionHandler exceptionHandler)
      • getBatchSize

        public int getBatchSize()
      • setBatchSize

        public void setBatchSize​(int batchSize)
        Sets the in batch size. This is the number of incoming exchanges that this batch processor will process before its completed. The default value is DEFAULT_BATCH_SIZE.
        Parameters:
        batchSize - the size
      • getOutBatchSize

        public int getOutBatchSize()
      • setOutBatchSize

        public void setOutBatchSize​(int outBatchSize)
        Sets the out batch size. If the batch processor holds more exchanges than this out size then the completion is triggered. Can for instance be used to ensure that this batch is completed when a certain number of exchanges has been collected. By default this feature is not enabled.
        Parameters:
        outBatchSize - the size
      • getBatchTimeout

        public long getBatchTimeout()
      • setBatchTimeout

        public void setBatchTimeout​(long batchTimeout)
      • isGroupExchanges

        public boolean isGroupExchanges()
      • setGroupExchanges

        public void setGroupExchanges​(boolean groupExchanges)
      • isBatchConsumer

        public boolean isBatchConsumer()
      • setBatchConsumer

        public void setBatchConsumer​(boolean batchConsumer)
      • isIgnoreInvalidExchanges

        public boolean isIgnoreInvalidExchanges()
      • setIgnoreInvalidExchanges

        public void setIgnoreInvalidExchanges​(boolean ignoreInvalidExchanges)
      • isReverse

        public boolean isReverse()
      • setReverse

        public void setReverse​(boolean reverse)
      • isAllowDuplicates

        public boolean isAllowDuplicates()
      • setAllowDuplicates

        public void setAllowDuplicates​(boolean allowDuplicates)
      • getCompletionPredicate

        public org.apache.camel.Predicate getCompletionPredicate()
      • setCompletionPredicate

        public void setCompletionPredicate​(org.apache.camel.Predicate completionPredicate)
      • getProcessor

        public org.apache.camel.Processor getProcessor()
      • next

        public List<org.apache.camel.Processor> next()
        Specified by:
        next in interface org.apache.camel.Navigate<org.apache.camel.Processor>
      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface org.apache.camel.Navigate<org.apache.camel.Processor>
      • getId

        public String getId()
        Specified by:
        getId in interface org.apache.camel.spi.HasId
      • setId

        public void setId​(String id)
        Specified by:
        setId in interface org.apache.camel.spi.IdAware
      • getRouteId

        public String getRouteId()
        Specified by:
        getRouteId in interface org.apache.camel.spi.RouteIdAware
      • setRouteId

        public void setRouteId​(String routeId)
        Specified by:
        setRouteId in interface org.apache.camel.spi.RouteIdAware
      • createSet

        protected static Set<org.apache.camel.Exchange> createSet​(org.apache.camel.Expression expression,
                                                                  boolean allowDuplicates,
                                                                  boolean reverse)
      • createSet

        protected static Set<org.apache.camel.Exchange> createSet​(Comparator<? super org.apache.camel.Exchange> comparator,
                                                                  boolean allowDuplicates,
                                                                  boolean reverse)
      • processExchange

        protected void processExchange​(org.apache.camel.Exchange exchange)
        Strategy Method to process an exchange in the batch. This method allows derived classes to perform custom processing before or after an individual exchange is processed
      • postProcess

        protected void postProcess​(org.apache.camel.Exchange exchange)
      • doBuild

        protected void doBuild()
                        throws Exception
        Overrides:
        doBuild in class org.apache.camel.support.service.BaseService
        Throws:
        Exception
      • doInit

        protected void doInit()
                       throws Exception
        Overrides:
        doInit in class org.apache.camel.support.service.BaseService
        Throws:
        Exception
      • doStart

        protected void doStart()
                        throws Exception
        Overrides:
        doStart in class org.apache.camel.support.AsyncProcessorSupport
        Throws:
        Exception
      • doStop

        protected void doStop()
                       throws Exception
        Overrides:
        doStop in class org.apache.camel.support.AsyncProcessorSupport
        Throws:
        Exception
      • process

        public boolean process​(org.apache.camel.Exchange exchange,
                               org.apache.camel.AsyncCallback callback)
        Enqueues an exchange for later batch processing.
        Specified by:
        process in interface org.apache.camel.AsyncProcessor