public class Throttler extends DelegateAsyncProcessor implements Traceable, IdAware
processor
shutdown, 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, setProcessor
doResume, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
public Throttler(CamelContext camelContext, Processor processor, Expression maxRequestsPerPeriodExpression, long timePeriodMillis, ScheduledExecutorService asyncExecutor, boolean shutdownAsyncExecutor, boolean rejectExecution, Expression correlation)
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.protected boolean processAsynchronously(Exchange exchange, AsyncCallback callback, org.apache.camel.processor.Throttler.ThrottlingState throttlingState)
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 DelegateAsyncProcessor
Exception
public 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()
Traceable
getTraceLabel
in interface Traceable
public String toString()
toString
in class DelegateAsyncProcessor
Apache Camel