A throttler is a processor that limits the flow rate of incoming
messages. You can use this pattern to protect a target endpoint from getting overloaded. In
FUSE Mediation Router, you can implement the throttler pattern using the throttler()
Java
DSL command.
To limit the flow rate to 100 messages per second, define a route as follows:
from("seda:a").throttler(100).to("seda:b");
If necessary, you can customize the time period that governs the flow rate using the
timePeriodMillis()
DSL command. For example, to limit the flow rate to 3
messages per 30000 milliseconds, define a route as follows:
from("seda:a").throttler(3).timePeriodMillis(30000).to("mock:result");
The following example shows how to configure the preceding route in XML:
<camelContext id="throttlerRoute" xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="seda:a"/> <throttler maximumRequestsPerPeriod="3" timePeriodMillis="30000"> <to uri="mock:result"/> </throttler> </route> </camelContext>