public class Throttler extends DelegateAsyncProcessor implements Traceable, IdAware
processorshutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending| Constructor and Description |
|---|
Throttler(CamelContext camelContext,
Processor processor,
Expression maxRequestsPerPeriodExpression,
long timePeriodMillis,
ScheduledExecutorService asyncExecutor,
boolean shutdownAsyncExecutor,
boolean rejectExecution,
Expression correlation) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doShutdown()
Implementations override this method to perform customized shutdown.
|
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
int |
getCurrentMaximumRequestsPerPeriod()
Gets the current maximum request per period value.
|
String |
getId()
Returns the id
|
Expression |
getMaximumRequestsPerPeriodExpression() |
long |
getTimePeriodMillis() |
String |
getTraceLabel()
Gets the trace label used for logging when tracing is enabled.
|
boolean |
isAsyncDelayed() |
boolean |
isCallerRunsWhenRejected() |
boolean |
isRejectExecution() |
boolean |
process(Exchange exchange,
AsyncCallback callback)
Processes the message exchange.
|
protected boolean |
processAsynchronously(Exchange exchange,
AsyncCallback callback,
org.apache.camel.processor.Throttler.ThrottlingState throttlingState)
Delegate blocking on the DelayQueue to an asyncExecutor.
|
void |
setAsyncDelayed(boolean asyncDelayed) |
void |
setCallerRunsWhenRejected(boolean callerRunsWhenRejected) |
void |
setId(String id)
Sets the id
|
void |
setMaximumRequestsPerPeriodExpression(Expression maxRequestsPerPeriodExpression)
Sets the maximum number of requests per time period expression
|
void |
setRejectExecution(boolean rejectExecution) |
void |
setTimePeriodMillis(long timePeriodMillis)
Sets the time period during which the maximum number of requests apply
|
String |
toString() |
doStop, getProcessor, hasNext, next, process, processNext, setProcessor, setProcessordoResume, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendpublic Throttler(CamelContext camelContext, Processor processor, Expression maxRequestsPerPeriodExpression, long timePeriodMillis, ScheduledExecutorService asyncExecutor, boolean shutdownAsyncExecutor, boolean rejectExecution, Expression correlation)
public boolean process(Exchange exchange, AsyncCallback callback)
AsyncProcessorProcessor.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 AsyncProcessorprocess in class DelegateAsyncProcessorexchange - 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.protected boolean processAsynchronously(Exchange exchange, AsyncCallback callback, org.apache.camel.processor.Throttler.ThrottlingState throttlingState)
protected void doStart() throws Exception
ServiceSupportServiceSupport.doStop() for more details.doStart in class DelegateAsyncProcessorExceptionServiceSupport.doStop()protected void doShutdown() throws Exception
ServiceSupportdoShutdown in class DelegateAsyncProcessorExceptionpublic boolean isRejectExecution()
public void setRejectExecution(boolean rejectExecution)
public boolean isAsyncDelayed()
public void setAsyncDelayed(boolean asyncDelayed)
public boolean isCallerRunsWhenRejected()
public void setCallerRunsWhenRejected(boolean callerRunsWhenRejected)
public void setMaximumRequestsPerPeriodExpression(Expression maxRequestsPerPeriodExpression)
public Expression getMaximumRequestsPerPeriodExpression()
public int getCurrentMaximumRequestsPerPeriod()
public void setTimePeriodMillis(long timePeriodMillis)
public long getTimePeriodMillis()
public String getTraceLabel()
TraceablegetTraceLabel in interface Traceablepublic String toString()
toString in class DelegateAsyncProcessorApache Camel