@Metadata(label="eip,routing") public class ThrottleDefinition extends ExpressionNode implements ExecutorServiceAwareDefinition<ThrottleDefinition>
inheritErrorHandler, log
Constructor and Description |
---|
ThrottleDefinition() |
ThrottleDefinition(Expression maximumRequestsPerPeriod) |
ThrottleDefinition(Expression maximumRequestsPerPeriod,
Expression correlationExpression) |
Modifier and Type | Method and Description |
---|---|
ThrottleDefinition |
asyncDelayed()
Enables asynchronous delay which means the thread will not block while delaying.
|
ThrottleDefinition |
callerRunsWhenRejected(boolean callerRunsWhenRejected)
Whether or not the caller should run the task when it was rejected by the thread pool.
|
Processor |
createProcessor(RouteContext routeContext)
Override this in definition class and implement logic to create the processor
based on the definition model.
|
protected String |
description() |
ThrottleDefinition |
executorService(ExecutorService executorService)
To use a custom thread pool (ScheduledExecutorService) by the throttler.
|
ThrottleDefinition |
executorServiceRef(String executorServiceRef)
To use a custom thread pool (ScheduledExecutorService) by the throttler.
|
Boolean |
getAsyncDelayed() |
Boolean |
getCallerRunsWhenRejected() |
ExpressionSubElementDefinition |
getCorrelationExpression() |
ExecutorService |
getExecutorService()
Gets the executor service
|
String |
getExecutorServiceRef()
Gets the reference to lookup in the
Registry for the executor service to be used. |
String |
getLabel()
Returns a label to describe this node such as the expression if some kind of expression node
|
Boolean |
getRejectExecution() |
String |
getShortName()
Returns a short name for this node which can be useful for ID generation or referring to related resources like images
|
Long |
getTimePeriodMillis() |
ThrottleDefinition |
maximumRequestsPerPeriod(long maximumRequestsPerPeriod)
Sets the time period during which the maximum request count per period
|
ThrottleDefinition |
rejectExecution(boolean rejectExecution)
Whether or not throttler throws the ThrottlerRejectedExecutionException when the exchange exceeds the request limit
Is by default false
|
void |
setAsyncDelayed(Boolean asyncDelayed) |
void |
setCallerRunsWhenRejected(Boolean callerRunsWhenRejected) |
void |
setCorrelationExpression(ExpressionSubElementDefinition correlationExpression)
The expression used to calculate the correlation key to use for throttle grouping.
|
void |
setExecutorService(ExecutorService executorService)
Sets the executor service to be used.
|
void |
setExecutorServiceRef(String executorServiceRef)
Sets a reference to lookup in the
Registry for the executor service to be used. |
void |
setExpression(ExpressionDefinition expression)
Expression to configure the maximum number of messages to throttle per request
|
void |
setRejectExecution(Boolean rejectExecution) |
void |
setTimePeriodMillis(Long timePeriodMillis) |
ThrottleDefinition |
timePeriodMillis(long timePeriodMillis)
Sets the time period during which the maximum request count is valid for
|
String |
toString() |
configureChild, createFilterProcessor, createPredicate, getExpression, getOutputs, isOutputSupported, preCreateProcessor, setOutputs
addInterceptStrategies, addInterceptStrategy, addOutput, addRoutes, aggregate, aggregate, aggregate, aggregate, aop, attribute, bean, bean, bean, bean, bean, bean, bean, bean, beanRef, beanRef, beanRef, beanRef, beanRef, choice, claimCheck, claimCheck, claimCheck, claimCheck, clearOutput, convertBodyTo, convertBodyTo, createChannel, createChildProcessor, createCompositeProcessor, createOutputsProcessor, createOutputsProcessor, createOutputsProcessorImpl, createProcessor, delay, delay, delay, doTry, dynamicRouter, dynamicRouter, end, endChoice, endDoTry, endHystrix, endParent, endRest, enrich, enrich, enrich, enrich, enrich, enrichRef, enrichRef, enrichRef, enrichWith, enrichWith, enrichWith, filter, filter, filter, filter, getIndex, getInterceptStrategies, getOtherAttributes, getParent, hystrix, id, idempotentConsumer, idempotentConsumer, idempotentConsumer, idempotentConsumer, inheritErrorHandler, inOnly, inOnly, inOnly, inOnly, inOnly, inOnly, inOut, inOut, inOut, inOut, inOut, inOut, isAbstract, isInheritErrorHandler, isTopLevelOnly, isWrappingEntireOutput, loadBalance, loadBalance, log, log, log, log, log, log, loop, loop, loop, loopDoWhile, loopDoWhile, makeProcessor, markRollbackOnly, markRollbackOnlyLast, marshal, marshal, marshal, marshal, multicast, multicast, multicast, onCompletion, onException, onException, pipeline, pipeline, pipeline, pipeline, placeholder, policy, policy, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrichRef, pollEnrichRef, pollEnrichWith, pollEnrichWith, pollEnrichWith, process, process, process, processRef, recipientList, recipientList, recipientList, recipientList, removeFaultHeader, removeHeader, removeHeaders, removeHeaders, removeProperties, removeProperties, removeProperty, resequence, resequence, rollback, rollback, routeDescription, routeGroup, routeId, routingSlip, routingSlip, routingSlip, routingSlip, routingSlip, routingSlip, routingSlip, saga, sample, sample, sample, script, script, serviceCall, serviceCall, serviceCall, setBody, setBody, setBody, setBody, setExchangePattern, setFaultBody, setFaultHeader, setHeader, setHeader, setHeader, setInheritErrorHandler, setOtherAttributes, setOutHeader, setOutHeader, setParent, setProperty, setProperty, sort, sort, sort, split, split, split, startupOrder, stop, threads, threads, threads, threads, throttle, throttle, throttle, throttle, throttle, throwException, throwException, to, to, to, to, to, to, to, to, to, to, toD, toD, toD, toF, transacted, transacted, transform, transform, unmarshal, unmarshal, unmarshal, unmarshal, validate, validate, validate, wireTap, wireTap, wireTap, wireTap, wireTap, wireTap, wireTap, wireTap, wireTap, wrapChannel, wrapChannel, wrapInErrorHandler, wrapProcessor
description, description, getCustomId, getDescription, getDescriptionText, getId, hasCustomIdAssigned, idOrCreate, setCustomId, setDescription, setId
public ThrottleDefinition()
public ThrottleDefinition(Expression maximumRequestsPerPeriod)
public ThrottleDefinition(Expression maximumRequestsPerPeriod, Expression correlationExpression)
protected String description()
public String getShortName()
NamedNode
getShortName
in interface NamedNode
public String getLabel()
ProcessorDefinition
getLabel
in interface NamedNode
getLabel
in class ExpressionNode
public Processor createProcessor(RouteContext routeContext) throws Exception
ProcessorDefinition
createProcessor
in class ProcessorDefinition<ExpressionNode>
Exception
public ThrottleDefinition timePeriodMillis(long timePeriodMillis)
timePeriodMillis
- period in millispublic ThrottleDefinition maximumRequestsPerPeriod(long maximumRequestsPerPeriod)
maximumRequestsPerPeriod
- the maximum request count number per time periodpublic ThrottleDefinition callerRunsWhenRejected(boolean callerRunsWhenRejected)
callerRunsWhenRejected
- whether or not the caller should runpublic ThrottleDefinition asyncDelayed()
public ThrottleDefinition rejectExecution(boolean rejectExecution)
rejectExecution
- throw the RejectExecutionException if the exchange exceeds the request limitpublic ThrottleDefinition executorService(ExecutorService executorService)
executorService
in interface ExecutorServiceAwareDefinition<ThrottleDefinition>
executorService
- the custom thread pool (must be scheduled)public ThrottleDefinition executorServiceRef(String executorServiceRef)
executorServiceRef
in interface ExecutorServiceAwareDefinition<ThrottleDefinition>
executorServiceRef
- the reference id of the thread pool (must be scheduled)public void setExpression(ExpressionDefinition expression)
setExpression
in class ExpressionNode
public Long getTimePeriodMillis()
public void setTimePeriodMillis(Long timePeriodMillis)
public Boolean getAsyncDelayed()
public void setAsyncDelayed(Boolean asyncDelayed)
public Boolean getCallerRunsWhenRejected()
public void setCallerRunsWhenRejected(Boolean callerRunsWhenRejected)
public ExecutorService getExecutorService()
ExecutorServiceAware
getExecutorService
in interface ExecutorServiceAware
public void setExecutorService(ExecutorService executorService)
ExecutorServiceAware
setExecutorService
in interface ExecutorServiceAware
executorService
- the executorpublic String getExecutorServiceRef()
ExecutorServiceAware
Registry
for the executor service to be used.getExecutorServiceRef
in interface ExecutorServiceAware
public void setExecutorServiceRef(String executorServiceRef)
ExecutorServiceAware
Registry
for the executor service to be used.setExecutorServiceRef
in interface ExecutorServiceAware
executorServiceRef
- reference for the executorpublic Boolean getRejectExecution()
public void setRejectExecution(Boolean rejectExecution)
public void setCorrelationExpression(ExpressionSubElementDefinition correlationExpression)
public ExpressionSubElementDefinition getCorrelationExpression()
Apache Camel