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.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
processorFields 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
ConstructorsConstructorDescriptionDelayProcessorSupport(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
Modifier and TypeMethodDescriptionprotected abstract longcalculateDelay(org.apache.camel.Exchange exchange) protected longprotected voiddelay(long delay, org.apache.camel.Exchange exchange) Delays the given time before continuing.protected voidprotected voiddoStart()intGets the current number ofExchanges being delayed (hold back due throttle limit hit)protected voidhandleSleepInterruptedException(InterruptedException e, org.apache.camel.Exchange exchange) Called when a sleep is interrupted; allows derived classes to handle this case differentlybooleanbooleanbooleanprocess(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
doBuild, doInit, doStop, getProcessor, hasNext, next, setProcessor, setProcessor, toStringMethods inherited from class org.apache.camel.support.AsyncProcessorSupport
process, processAsyncMethods inherited from class org.apache.camel.support.service.BaseService
build, doFail, doLifecycleChange, doResume, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.camel.Processor
processMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
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 Details
-
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
Delays 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
- Overrides:
doStartin classorg.apache.camel.support.processor.DelegateAsyncProcessor- Throws:
Exception
-
doShutdown
- Overrides:
doShutdownin classorg.apache.camel.support.processor.DelegateAsyncProcessor- Throws:
Exception
-