[ 
https://issues.apache.org/jira/browse/CAMEL-4692?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Bilgin Ibryam updated CAMEL-4692:
---------------------------------

    Attachment: routePolicy.diff

ScheduledRoutePolicy was working only with one route (the first one assigned) 
at a time. I tried to fix that by introducing a map (a little bit refactoring) 
to store the routes using the same policy.

Julian, can you give it a try?
                
> can't use same route policy on two routes
> -----------------------------------------
>
>                 Key: CAMEL-4692
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4692
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.8.2
>         Environment: tomcat6
>            Reporter: Julian Cable
>         Attachments: routePolicy.diff
>
>
> The following XML DSL defines two routes using the same route policy:
> <beans xmlns="http://www.springframework.org/schema/beans";
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>        xmlns:camel="http://camel.apache.org/schema/spring";
>        xsi:schemaLocation="
>        http://www.springframework.org/schema/beans 
> http://www.springframework.org/schema/beans/spring-beans.xsd
>        http://camel.apache.org/schema/spring 
> http://camel.apache.org/schema/spring/camel-spring.xsd";>
>   <camel:camelContext xmlns="http://camel.apache.org/schema/spring";>
>     <camel:propertyPlaceholder id="properties" 
> location="file:///etc/camel/css.properties"/>
>     <camel:package>cdp_test</camel:package>
>     <camel:route id="r1" routePolicyRef="pol1">
>       <camel:from uri="file://data/1"/>
>       <camel:to uri="stream:out"/>
>     </camel:route>
>     <camel:route id="r2" routePolicyRef="pol1">
>       <camel:from uri="file://data/2"/>
>       <camel:to uri="stream:out"/>
>     </camel:route>
>   </camel:camelContext>
>   <bean id="pol1" 
> class="org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy">
>     <property name="routeStartTime" value="00,30 * * * * ? *"/>
>     <property name="routeStopTime"  value="10,40 * * * * ? *"/>
>   </bean>
> </beans>
> This is the logging output. r2 does not follow the policy:
> [pache.camel.spring.Main.main()] StdSchedulerFactory            INFO  Quartz 
> scheduler 'DefaultQuartzScheduler-camel-1' initialized from an externally 
> provided properties instance.
> [pache.camel.spring.Main.main()] StdSchedulerFactory            INFO  Quartz 
> scheduler version: 1.8.4
> [pache.camel.spring.Main.main()] ScheduledRoutePolicy           INFO  
> Scheduled trigger: triggerGroup-r1.trigger-START-r1 for action: START on 
> route:
> [pache.camel.spring.Main.main()] ScheduledRoutePolicy           INFO  
> Scheduled trigger: triggerGroup-r1.trigger-STOP-r1 for action: STOP on route:
> [pache.camel.spring.Main.main()] SpringCamelContext             INFO  Route: 
> r1 started and consuming from: Endpoint[file://data/1]
> [pache.camel.spring.Main.main()] SpringCamelContext             INFO  Route: 
> r2 started and consuming from: Endpoint[file://data/2]
> [pache.camel.spring.Main.main()] QuartzComponent                INFO  
> Starting Quartz scheduler: DefaultQuartzScheduler-camel-1
> [pache.camel.spring.Main.main()] QuartzScheduler                INFO  
> Scheduler DefaultQuartzScheduler-camel-1_$_NON_CLUSTERED started.
> [pache.camel.spring.Main.main()] SpringCamelContext             INFO  Total 2 
> routes, of which 2 is started.
> [pache.camel.spring.Main.main()] SpringCamelContext             INFO  Apache 
> Camel 2.8.2 (CamelContext: camel-1) started in 0.596 seconds
> hello 1
> [artzScheduler-camel-1_Worker-2] DefaultShutdownStrategy        INFO  
> Starting to graceful shutdown 1 routes (timeout 10000 milliseconds)
> [el-1) thread #2 - ShutdownTask] DefaultShutdownStrategy        INFO  Route: 
> r1 shutdown complete, was consuming from: Endpoint[file://data/1]
> [artzScheduler-camel-1_Worker-2] DefaultShutdownStrategy        INFO  
> Graceful shutdown of 1 routes completed in 0 seconds
> [artzScheduler-camel-1_Worker-2] SpringCamelContext             INFO  Route: 
> r1 stopped, was consuming from: Endpoint[file://data/1]
> hello 2
> hello 2
> [artzScheduler-camel-1_Worker-3] SpringCamelContext             INFO  Route: 
> r1 started and consuming from: Endpoint[file://data/1]
> hello 2
> [artzScheduler-camel-1_Worker-4] DefaultShutdownStrategy        INFO  
> Starting to graceful shutdown 1 routes (timeout 10000 milliseconds)
> [el-1) thread #2 - ShutdownTask] DefaultShutdownStrategy        INFO  Route: 
> r1 shutdown complete, was consuming from: Endpoint[file://data/1]
> [artzScheduler-camel-1_Worker-4] DefaultShutdownStrategy        INFO  
> Graceful shutdown of 1 routes completed in 0 seconds
> [artzScheduler-camel-1_Worker-4] SpringCamelContext             INFO  Route: 
> r1 stopped, was consuming from: Endpoint[file://data/1]
> If I use two separate identical route policies it works as I expect.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to