Class DelayProcessorSupport

  • All Implemented Interfaces:
    AutoCloseable, org.apache.camel.AsyncProcessor, org.apache.camel.DelegateProcessor, org.apache.camel.Navigate<org.apache.camel.Processor>, org.apache.camel.Processor, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.StatefulService, org.apache.camel.SuspendableService
    Direct Known Subclasses:
    Delayer

    public abstract class DelayProcessorSupport
    extends org.apache.camel.support.processor.DelegateAsyncProcessor
    A useful base class for any processor which provides some kind of throttling or delayed processing.

    This implementation will block while waiting.

    • Field Summary

      • Fields inherited from class org.apache.camel.support.processor.DelegateAsyncProcessor

        processor
      • 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
      DelayProcessorSupport​(org.apache.camel.CamelContext camelContext, org.apache.camel.Processor processor)  
      DelayProcessorSupport​(org.apache.camel.CamelContext camelContext, org.apache.camel.Processor processor, ScheduledExecutorService executorService, boolean shutdownExecutorService)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract long calculateDelay​(org.apache.camel.Exchange exchange)  
      protected long currentSystemTime()  
      protected void delay​(long delay, org.apache.camel.Exchange exchange)
      Delays the given time before continuing.
      protected void doShutdown()  
      protected void doStart()  
      int getDelayedCount()
      Gets the current number of Exchanges being delayed (hold back due throttle limit hit)
      protected void handleSleepInterruptedException​(InterruptedException e, org.apache.camel.Exchange exchange)
      Called when a sleep is interrupted; allows derived classes to handle this case differently
      boolean isAsyncDelayed()  
      boolean isCallerRunsWhenRejected()  
      boolean process​(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback)  
      protected boolean processDelay​(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback, long delay)  
      void setAsyncDelayed​(boolean asyncDelayed)  
      void setCallerRunsWhenRejected​(boolean callerRunsWhenRejected)  
      • Methods inherited from class org.apache.camel.support.processor.DelegateAsyncProcessor

        doBuild, doInit, doStop, getProcessor, hasNext, next, setProcessor, setProcessor, toString
      • 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 interface org.apache.camel.Processor

        process
      • 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 Detail

      • DelayProcessorSupport

        public DelayProcessorSupport​(org.apache.camel.CamelContext camelContext,
                                     org.apache.camel.Processor processor)
      • DelayProcessorSupport

        public DelayProcessorSupport​(org.apache.camel.CamelContext camelContext,
                                     org.apache.camel.Processor processor,
                                     ScheduledExecutorService executorService,
                                     boolean shutdownExecutorService)
    • Method Detail

      • processDelay

        protected boolean processDelay​(org.apache.camel.Exchange exchange,
                                       org.apache.camel.AsyncCallback callback,
                                       long delay)
      • process

        public boolean process​(org.apache.camel.Exchange exchange,
                               org.apache.camel.AsyncCallback callback)
        Specified by:
        process in interface org.apache.camel.AsyncProcessor
        Overrides:
        process in class org.apache.camel.support.processor.DelegateAsyncProcessor
      • isAsyncDelayed

        public boolean isAsyncDelayed()
      • setAsyncDelayed

        public void setAsyncDelayed​(boolean asyncDelayed)
      • isCallerRunsWhenRejected

        public boolean isCallerRunsWhenRejected()
      • setCallerRunsWhenRejected

        public void setCallerRunsWhenRejected​(boolean callerRunsWhenRejected)
      • calculateDelay

        protected abstract long calculateDelay​(org.apache.camel.Exchange exchange)
      • getDelayedCount

        public int getDelayedCount()
        Gets the current number of Exchanges being delayed (hold back due throttle limit hit)
      • delay

        protected void delay​(long delay,
                             org.apache.camel.Exchange exchange)
                      throws InterruptedException
        Delays the given time before continuing.

        This implementation will block while waiting

        Parameters:
        delay - the delay time in millis
        exchange - the exchange being processed
        Throws:
        InterruptedException
      • currentSystemTime

        protected long currentSystemTime()
      • doStart

        protected void doStart()
                        throws Exception
        Overrides:
        doStart in class org.apache.camel.support.processor.DelegateAsyncProcessor
        Throws:
        Exception
      • doShutdown

        protected void doShutdown()
                           throws Exception
        Overrides:
        doShutdown in class org.apache.camel.support.processor.DelegateAsyncProcessor
        Throws:
        Exception