Devendra Pratap Singh created CAMEL-9288:
--------------------------------------------
Summary: Apache Camel Throttler component keeps rejecting trafffic
in next slot if current slot threshold is reached and more requests received in
current slot
Key: CAMEL-9288
URL: https://issues.apache.org/jira/browse/CAMEL-9288
Project: Camel
Issue Type: Bug
Components: camel-core
Affects Versions: 2.14.3, 2.14.2, 2.14.1, 2.14.0
Reporter: Devendra Pratap Singh
I have observed that apache-camel doesn't throttle the requests as expected
when the rejectExecution(see below) is true
<throttle timePeriodMillis="10000" rejectExecution="true">
<constant>4</constant>
<to uri="mock:result"/>
</throttle>
Following is code snippet from org.apache.camel.processor.Throttle class
protected long calculateDelay(Exchange exchange) {
......
TimeSlot slot = nextSlot();
if (!slot.isActive()) {
long delay = slot.startTime - currentSystemTime();
return delay;
} else {
return 0;
}
}
/*
*Determine what the next available time slot is for handling an Exchange
*/
protected synchronized TimeSlot nextSlot() {
if (slot == null) {
slot = new TimeSlot();
}
if (slot.isFull() || !slot.isPast()) {
slot = slot.next();
}
slot.assign();
return slot;
}
As per above snippet whenever a slot is full and a new request arrives, then a
new slot beginning after the current slot is created and slot.assign() is
invoked to reduce the capacity of this newly created slot to accommodate
current request which according to me is faulty as there will be a delay in
processing this new request and as per the Throttler code whenever there is a
delay and rejectExecution = true a
org.apache.camel.processor.ThrottlerRejectedExecutionException is thrown. It's
obvious that even though the Throttler component is rejecting the new request
after the threshold is reached still it is reducing the capacity of the next
slot which will allow one less request to be processed in the next slot rather
than the same number as of previous slot.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)