You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dermoritz <ta...@hotmail.com> on 2014/11/28 13:54:25 UTC
Starting a rout once on start and then always at 3am
I have a route using jdbc component to fetch some data from db.
so my idea is:
from("quartz:<cron expression for 3am>").to(jdbc:...)
My problem is that "fireNow" seems only to work for simple timer. Is there
an easy way to fire the route once at start (after first run this route
triggers start of other routes.)?
--
View this message in context: http://camel.465427.n5.nabble.com/Starting-a-rout-once-on-start-and-then-always-at-3am-tp5759767.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Starting a rout once on start and then always at 3am
Posted by sathiyaraja <sa...@hotmail.com>.
<bean id="date" class="org.apache.camel.routepolicy.quartz.SimpleDate"/>
<bean id="startPolicy"
class="org.apache.camel.routepolicy.quartz.SimpleScheduledRoutePolicy">
<property name="routeStartTime" value="time"/>
</bean>
<camelContext id="testRouteContext"
xmlns="http://camel.apache.org/schema/spring">
<route id="testRoute" autoStartup="false" routePolicyRef="startPolicy">
<from uri="seda:foo?concurrentConsumers=20"/>
<to uri="mock:result"/>
</route>
</camelContext>
</route>
In from uri u can give a dummy timer to start ur route.
--
View this message in context: http://camel.465427.n5.nabble.com/Starting-a-rout-once-on-start-and-then-always-at-3am-tp5759767p5759832.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Starting a rout once on start and then always at 3am
Posted by dermoritz <ta...@hotmail.com>.
thanks in meanwhile i took the 2 routes way.
it's working fine and fits well.
but i 'll think about your three route approach.
--
View this message in context: http://camel.465427.n5.nabble.com/Starting-a-rout-once-on-start-and-then-always-at-3am-tp5759767p5760018.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Starting a rout once on start and then always at 3am
Posted by Marco Westermann <Ma...@gmx.de>.
you can split your original route into three ones like that:
from("direct:process")
.to(jdbc)
.whatever;
from("timer:myTimer? repeatCount=1")
.to("direct:process");
from("quarz:cron")
.to("direct:process");
that way the direct:process route gets triggerd by the timer and the
quarz routes.
regards
Am 28.11.2014 15:13, schrieb dermoritz:
> you mean i should create 2 routes:
>
> from(timer:repeateOnce).to(jdbc)
> and
> from(timer:cronExpr).to(jdbc)
> ?
>
> thats not very beautiful but a good option.
>
> What about (came to mind in meanwhile):
>
> from(timer:cronExpr).to(direct:startNow).to(jdbc:)
>
> does this work?
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Starting-a-rout-once-on-start-and-then-always-at-3am-tp5759767p5759769.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Re: Starting a rout once on start and then always at 3am
Posted by dermoritz <ta...@hotmail.com>.
you mean i should create 2 routes:
from(timer:repeateOnce).to(jdbc)
and
from(timer:cronExpr).to(jdbc)
?
thats not very beautiful but a good option.
What about (came to mind in meanwhile):
from(timer:cronExpr).to(direct:startNow).to(jdbc:)
does this work?
--
View this message in context: http://camel.465427.n5.nabble.com/Starting-a-rout-once-on-start-and-then-always-at-3am-tp5759767p5759769.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Starting a rout once on start and then always at 3am
Posted by Marco Westermann <Ma...@gmx.de>.
Hi,
you can use a second route with a timer and set the timer property
repeatCount to 1, so the timer will only fire once when the route is
started. Have a look here:
http://camel.apache.org/timer.html
regards Marco
Am 28.11.2014 13:54, schrieb dermoritz:
> I have a route using jdbc component to fetch some data from db.
>
> so my idea is:
> from("quartz:<cron expression for 3am>").to(jdbc:...)
>
> My problem is that "fireNow" seems only to work for simple timer. Is there
> an easy way to fire the route once at start (after first run this route
> triggers start of other routes.)?
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Starting-a-rout-once-on-start-and-then-always-at-3am-tp5759767.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>