camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (JIRA)" <>
Subject [jira] [Commented] (CAMEL-9355) Current Throttler implementation is not accurate and does not work in a multi-threaded route
Date Thu, 10 Dec 2015 07:06:11 GMT


Claus Ibsen commented on CAMEL-9355:

Please dont change the behavior of the child behavior of throttler with that true -> false.
And please keep the existing code formatting, that is the formatting we use.

The time taken is only used for trace logging, can you make it so that we don't capture that
detail if you do not use trace logging.

Also there is some code comment that says semaphore, i guess you should change that. And maybe
add a bit of code comment or class javadoc comment about the idea of this implementation using
a delayed queue. The logic that removes permits and whatnot is a bit complicated to understand
at first glance, so we need to help new users to this as the entire community should be able
to maintain the code ;)

But great work, good to see a better throttler implementation.

> Current Throttler implementation is not accurate and does not work in a multi-threaded
> --------------------------------------------------------------------------------------------
>                 Key: CAMEL-9355
>                 URL:
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.16.0
>            Reporter: Aaron Whiteside
>         Attachments: CAMEL_9355.patch, CAMEL_9355v2.patch
> Current Throttler implementation is not accurate and is even more inaccurate in a multi-threaded
route (think sjms....consumerCount=100).
> The delay to sleep cannot be calculated ahead of time in a multi-threaded environment,
to this end the Throttler should not extend DelayProcessorSupport.
> Attached is a patch that changes throttler to use a Semaphore to do accurate and multi-thread
safe throttling.
> The code I think is much cleaner, smaller and easier to understand. Than it used to be
> Unit tests still pass, I had to make some changes to ThrottlerTest as it made assumptions
about the implementation and was doing bad things like adding a 750ms buffer to validating
the minimum throttle delay.. ThrottlerTest is now very sane.
> I've also implemented support to allow the throttler construct to be used without any
nested outputs. For example the follow code is now valid.
> {code}
> <throttle><constant>100</constant></throttle> 
> {code}
> If you want to disable this feature it can be done in ThrottlerDefinition::createProcessor()
line 82 changing false to true.
> I think this allows more flexible usage of the throttler, in my use case I want to delay
the further execution of the route, and I don't want to have to split my routes up into separate
sub-routes to be able to do that. 

This message was sent by Atlassian JIRA

View raw message