...
There are these callbacks invoked
onInit
Camel 2.3onRemove
Camel 2.9onStart
Camel 2.9onStop
Camel 2.9onSuspend
Camel 2.9onResume
Camel 2.9onExchangeBegin
onExchangeDone
See the javadoc of the org.apache.camel.spi.RoutePolicy
for more details.
And also the implementation of the org.apache.camel.impl.ThrottlingInflightRoutePolicy
for a concrete example.
Camel provides the following policies out of the box:
org.apache.camel.impl.ThrottlingInflightRoutePolicy
- a throttling based policy that automatic suspends/resumes route(s) based on metrics from the current in flight exchanges. You can use this to dynamic throttle e.g. a JMS consumer to avoid it consuming too fast.
As of Camel 2.5, Camel also provides an ability to schedule routes to be activated, de-activated, suspended and/or resumed at certain times during the day using a ScheduledRoutePolicy (offered via the camel-quartz component).
...
Code Block | ||||
---|---|---|---|---|
| ||||
<bean id="date" class="org.apache.camel.routepolicy.quartz.SimpleDate"/> <bean id="startPolicy" class="org.apache.camel.routepolicy.quartz.SimpleScheduledRoutePolicy"> <property name="routeStartDate" ref="date"/> <property name="routeStartRepeatCount" value="1"/> <property name="routeStartRepeatInterval" value="3000"/> </bean> <bean id="throttlePolicy" class="org.apache.camel.impl.ThrottlingInflightRoutePolicy"> <property name="maxInflightExchanges" value="10"/> </bean> <camelContext id="testRouteContext" xmlns="http://camel.apache.org/schema/spring"> <route id="testRoute" autoStartup="false" routePolicyRef="startPolicy, throttlePolicy"> <from uri="seda:foo?concurrentConsumers=20"/> <to uri="mock:result"/> </route> </camelContext> </route> |
See Also
- Route Throttling Example for an example using this in practice with the ThrottlingInflightRoutePolicy
- ScheduledRoutePolicy for information on policy based scheduling capability for camel routes
- Architecture