|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.camel.support.ServiceSupport org.apache.camel.processor.DelegateAsyncProcessor org.apache.camel.processor.DelayProcessorSupport
public abstract class DelayProcessorSupport
A useful base class for any processor which provides some kind of throttling or delayed processing.
This implementation will block while waiting.
Field Summary | |
---|---|
protected org.slf4j.Logger |
log
|
Fields inherited from class org.apache.camel.processor.DelegateAsyncProcessor |
---|
processor |
Fields inherited from class org.apache.camel.support.ServiceSupport |
---|
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending |
Constructor Summary | |
---|---|
DelayProcessorSupport(CamelContext camelContext,
Processor processor)
|
|
DelayProcessorSupport(CamelContext camelContext,
Processor processor,
ScheduledExecutorService executorService,
boolean shutdownExecutorService)
|
Method Summary | |
---|---|
protected abstract long |
calculateDelay(Exchange exchange)
|
protected long |
currentSystemTime()
|
protected void |
delay(long delay,
Exchange exchange)
Delays the given time before continuing. |
protected void |
doShutdown()
Implementations override this method to perform customized shutdown. |
protected void |
doStart()
Implementations override this method to support customized start/stop. |
int |
getDelayedCount()
Gets the current number of Exchange s being delayed (hold back due throttle limit hit) |
protected void |
handleSleepInterruptedException(InterruptedException e,
Exchange exchange)
Called when a sleep is interrupted; allows derived classes to handle this case differently |
boolean |
isAsyncDelayed()
|
boolean |
isCallerRunsWhenRejected()
|
boolean |
process(Exchange exchange,
AsyncCallback callback)
Processes the message exchange. |
void |
setAsyncDelayed(boolean asyncDelayed)
|
void |
setCallerRunsWhenRejected(boolean callerRunsWhenRejected)
|
Methods inherited from class org.apache.camel.processor.DelegateAsyncProcessor |
---|
doStop, getProcessor, hasNext, next, process, processNext, setProcessor, setProcessor, toString |
Methods inherited from class org.apache.camel.support.ServiceSupport |
---|
doResume, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, resume, shutdown, start, stop, suspend |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final org.slf4j.Logger log
Constructor Detail |
---|
public DelayProcessorSupport(CamelContext camelContext, Processor processor)
public DelayProcessorSupport(CamelContext camelContext, Processor processor, ScheduledExecutorService executorService, boolean shutdownExecutorService)
Method Detail |
---|
public boolean process(Exchange exchange, AsyncCallback callback)
AsyncProcessor
Processor.process(org.apache.camel.Exchange)
, but the caller supports having the exchange asynchronously processed.
If there was a failure processing then the caused Exception
would be set on the Exchange
.
process
in interface AsyncProcessor
process
in class DelegateAsyncProcessor
exchange
- the message exchangecallback
- the AsyncCallback
will be invoked when the processing of the exchange is completed.
If the exchange is completed synchronously, then the callback is also invoked synchronously.
The callback should therefore be careful of starting recursive loop.
public boolean isAsyncDelayed()
public void setAsyncDelayed(boolean asyncDelayed)
public boolean isCallerRunsWhenRejected()
public void setCallerRunsWhenRejected(boolean callerRunsWhenRejected)
protected abstract long calculateDelay(Exchange exchange)
public int getDelayedCount()
Exchange
s being delayed (hold back due throttle limit hit)
protected void delay(long delay, Exchange exchange) throws InterruptedException
delay
- the delay time in millisexchange
- the exchange being processed
InterruptedException
protected void handleSleepInterruptedException(InterruptedException e, Exchange exchange) throws InterruptedException
InterruptedException
protected long currentSystemTime()
protected void doStart() throws Exception
ServiceSupport
ServiceSupport.doStop()
for more details.
doStart
in class DelegateAsyncProcessor
Exception
ServiceSupport.doStop()
protected void doShutdown() throws Exception
ServiceSupport
doShutdown
in class ServiceSupport
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |