Peter Kirby
Peter Kirby

Reputation: 1985

Throttling with Concurrent Consumers

According to Camel's documentation on the Throttler EIP, a route like the following would allow no more than 10 messages to hit the queue:b endpoint in any given 1000 millisecond period:

from("queue:a").throttle(10).to("queue:b");

I am having trouble finding documentation that explains whether or not throttling is done on a per-thread basis or a per route basis. Given the following route, will each consumer be allowed to send no more than 10 messages to queue:b, or will the entirety of all consumers be restricted to 10 messages per unit time?

from("queue:a?concurrentConsumers=20")
    .to("bean:myBean?method=doSomeExpensiveLongRunningCalculations)
    .throttle(10).asyncDelayed()
    .to("bean:myBean?method=makeAPICallToExternalService")
    .to("bean:myBean?method=performMoreCalculationsAndSave");

The reason I must throttle above is due to a rate limit imposed by a third-party API.

Any help would be appreciated!

Thanks

Upvotes: 0

Views: 1564

Answers (1)

Claus Ibsen
Claus Ibsen

Reputation: 55540

Its global, so its 10 per second no matter which consumer threads are used to send the message to the throttler.

Upvotes: 2

Related Questions