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 throttle() Java DSL
command.
To limit the flow rate to 100 messages per second, define a route as follows:
from("seda:a").throttle(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").throttle(3).timePeriodMillis(30000).to("mock:result");The following example shows how to configure the preceding route in XML:
<camelContext id="throttleRoute" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="seda:a"/>
<throttle maximumRequestsPerPeriod="3" timePeriodMillis="30000">
<to uri="mock:result"/>
</throttle>
</route>
</camelContext>The throttler can enable non-blocking asynchronous delaying, which means that Fuse Mediation Router schedules a task to be executed in the future. The task is responsible for processing the latter part of the route (after the throttler). This allows the caller thread to unblock and service further incoming messages. For example:
from("seda:a").throttle(100).asyncDelayed().to("seda:b");







