Package org.apache.camel.processor
Class DelayProcessorSupport
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.AsyncProcessorSupport
-
- org.apache.camel.support.processor.DelegateAsyncProcessor
-
- org.apache.camel.processor.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.spi.ShutdownAware,org.apache.camel.spi.ShutdownPrepared,org.apache.camel.StatefulService,org.apache.camel.SuspendableService
- Direct Known Subclasses:
Delayer
public abstract class DelayProcessorSupport extends org.apache.camel.support.processor.DelegateAsyncProcessor implements org.apache.camel.spi.ShutdownAwareA useful base class for any processor which provides some kind of throttling or delayed processing. This implementation will block while waiting.
-
-
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 longcalculateDelay(org.apache.camel.Exchange exchange)protected longcurrentSystemTime()booleandeferShutdown(org.apache.camel.ShutdownRunningTask shutdownRunningTask)protected voiddelay(long delay, org.apache.camel.Exchange exchange)Delays the given time before continuing.protected voiddoShutdown()protected voiddoStart()intgetDelayedCount()Gets the current number ofExchanges being delayed (hold back due throttle limit hit)intgetPendingExchangesSize()protected voidhandleSleepInterruptedException(InterruptedException e, org.apache.camel.Exchange exchange)Called when a sleep is interrupted; allows derived classes to handle this case differentlybooleanisAsyncDelayed()booleanisCallerRunsWhenRejected()voidprepareShutdown(boolean suspendOnly, boolean forced)booleanprocess(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback)protected booleanprocessDelay(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback, long delay)voidsetAsyncDelayed(boolean asyncDelayed)voidsetCallerRunsWhenRejected(boolean callerRunsWhenRejected)-
Methods inherited from class org.apache.camel.support.processor.DelegateAsyncProcessor
doStop, getProcessor, hasNext, next, setProcessor, setProcessor, toString
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, 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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
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:
processin interfaceorg.apache.camel.AsyncProcessor- Overrides:
processin classorg.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 ofExchanges being delayed (hold back due throttle limit hit)
-
delay
protected void delay(long delay, org.apache.camel.Exchange exchange) throws InterruptedExceptionDelays the given time before continuing. This implementation will block while waiting- Parameters:
delay- the delay time in millisexchange- the exchange being processed- Throws:
InterruptedException
-
handleSleepInterruptedException
protected void handleSleepInterruptedException(InterruptedException e, org.apache.camel.Exchange exchange) throws InterruptedException
Called when a sleep is interrupted; allows derived classes to handle this case differently- Throws:
InterruptedException
-
currentSystemTime
protected long currentSystemTime()
-
doStart
protected void doStart() throws Exception- Overrides:
doStartin classorg.apache.camel.support.processor.DelegateAsyncProcessor- Throws:
Exception
-
doShutdown
protected void doShutdown() throws Exception- Overrides:
doShutdownin classorg.apache.camel.support.processor.DelegateAsyncProcessor- Throws:
Exception
-
deferShutdown
public boolean deferShutdown(org.apache.camel.ShutdownRunningTask shutdownRunningTask)
- Specified by:
deferShutdownin interfaceorg.apache.camel.spi.ShutdownAware
-
getPendingExchangesSize
public int getPendingExchangesSize()
- Specified by:
getPendingExchangesSizein interfaceorg.apache.camel.spi.ShutdownAware
-
prepareShutdown
public void prepareShutdown(boolean suspendOnly, boolean forced)- Specified by:
prepareShutdownin interfaceorg.apache.camel.spi.ShutdownPrepared
-
-