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
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
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 long
calculateDelay
(org.apache.camel.Exchange exchange) protected long
protected void
delay
(long delay, org.apache.camel.Exchange exchange) Delays the given time before continuing.protected void
protected void
doStart()
int
Gets the current number ofExchange
s 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 differentlyboolean
boolean
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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
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 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:
process
in interfaceorg.apache.camel.AsyncProcessor
- Overrides:
process
in 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 ofExchange
s 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:
doStart
in classorg.apache.camel.support.processor.DelegateAsyncProcessor
- Throws:
Exception
-
doShutdown
- Overrides:
doShutdown
in classorg.apache.camel.support.processor.DelegateAsyncProcessor
- Throws:
Exception
-