Configure a camel route to start and stop at certain time of day

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Configure a camel route to start and stop at certain time of day

briane80
Hi,

I have a requirement where my camel route should only pick up new messages between 8am and 10pm due to database backups and other nightly processes.

I have looked at the SimpleScheduledRoutePolicy class but i'm not sure how to use it to start and stop routes at predefined times every day. Cann someone provide an example of how to configure this (i'm using camel 2.12 and mainly xml based config).

Thanks,

Brian
Reply | Threaded
Open this post in threaded view
|

Re: Configure a camel route to start and stop at certain time of day

briane80
I think this will work (was easier than expected!):

In xml:

<bean id="timePolicy" class="org.apache.camel.routepolicy.quartz2.CronScheduledRoutePolicy">
  <property name="routeStartTime" value="0 0 8 * * ?"/>
                <property name="routeStopTime" value="0 0 22 * * ?"/>
</bean>

In route declaration:

from(routes.get(A2CMessageDefaultValues.TRANSPORT_INBOX)).routeId("A2cMessageService")
.routePolicyRef("timePolicy").beanRef("messagePreProcessor").choice()

....