Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
xml
xml
   <bean id="myPolicy" class="com.mycompany.MyRoutePolicy"/>
   
   <route routePolicyRef="myPolicy">
       <from uri="seda:foo"/>
       <to uri="mock:result"/>
   </route>

Configuring policy sets

Available as of Camel 2.7

RoutePolicy has been further improved to allow addition of policy sets or a collection of policies that are concurrently applied on a route. The addition of policies is done as follows.

In the example below, the route testRoute has a startPolicy and throttlePolicy applied concurrently. Both policies are applied as necessary on the route.

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:success"/>
        </route>
    </camelContext>
   </route>

See Also