Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

There are these callbacks invoked

  • onInit Camel 2.3
  • onRemove Camel 2.9
  • onStart Camel 2.9
  • onStop Camel 2.9
  • onSuspend Camel 2.9
  • onResume Camel 2.9
  • onExchangeBegin
  • 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
xml
xml
   <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