Throttler – restricting the number of messages flowing to an endpoint
When you need to limit the number of messages flowing through a route during a specified time period, the Throttler EIP can help. For example, if you have a downstream system that can only handle 10 requests per second, using a Throttler EIP within your route can ensure that you do not exceed that rate.
This recipe will show you how to restrict the number of messages routed to a set of endpoints during a specified time period.
Getting ready
The Java code for this recipe is located in the org.camelcookbook.routing.throttler
package. The Spring XML files are located under src/main/resources/META-INF/spring
and prefixed with throttler
.
How to do it...
In order to use the Throttler, perform the following steps:
- You must specify the maximum number of messages to be allowed per time period (defaults to 1,000 ms).
In the XML DSL, this is specified as an Expression to allow for the maximum rate to be changed at runtime. In this...