camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Borut Bolčina <borut.bolc...@gmail.com>
Subject Re: Scheduled route execution with CronScheduledRoutePolicy don't work as expected
Date Tue, 24 Apr 2012 14:54:05 GMT
Thanks for the clarification Claus!

-borut

Dne 24. april 2012 16:41 je Claus Ibsen <claus.ibsen@gmail.com> napisal/-a:

> Hi
>
> Its *not* the same.
>
> The 1st route is from quartz, which sends out a message every X period.
> You can configure that route to use cron as well.
>
> The 2nd route is from http, which mean you constantly poll a http
> endpoint by sending a http get, and routing the response, this will
> repeat itself as long as the route is running.
>
> The route policy will just tell when to start | stop a given route
> based on some policy. In your case you only have a start cron
> expression.
> You would need a stop as well. But as long the rout is running, the
> from http will run as fast as possible. And therefore you see so many
> calls in the logs.
>
>
>
>
>
> On Tue, Apr 24, 2012 at 2:45 PM, Borut Bolčina <borut.bolcina@gmail.com>
> wrote:
> > Hello,
> >
> > while this:
> >
> > public void configure() {
> >
>  from("quartz://myTimer?trigger.repeatInterval=2000&trigger.repeatCount=-1")
> >  .to("http://my.company.com/test.txt")
> >  .log("${body}");
> >  }
> >
> > nicely prints out the content of the test.txt to the console every 2
> > seconds;
> >
> > [2012/04/24 14:35:12.884] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:35:14.723] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:35:16.710] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:35:18.710] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:35:20.711] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:35:22.711] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:35:24.653] INFO  [main.MainSupport$HangupInterceptor:run]:
> > Received hang up - stopping the main instance.
> >
> > but the following code using CronScheduledRoutePolicy or
> > SimpleScheduledRoutePolicy:
> >
> > public void configure() {
> >  CronScheduledRoutePolicy cronPolicy = new CronScheduledRoutePolicy();
> > cronPolicy.setRouteStartTime("0/2 * * * * ?");
> >  from(" http://my.company.com/test.txt ")
> > .noAutoStartup()
> > .routePolicy(simpleScheduledPolicy)
> >  .log("${body}");
> > }
> >
> > starts consuming from the http endpoint (or at least printing out) every
> > few milliseconds instead of every 2 seconds:
> >
> > [2012/04/24 14:29:10.219] INFO  [main.MainSupport:doStart]: Apache Camel
> > 2.9.2 starting
> > [2012/04/24 14:29:11.239] INFO  [spring.SpringCamelContext:start]: Apache
> > Camel 2.9.2 (CamelContext: camel-1) is starting
> > [2012/04/24 14:29:11.241] INFO
> >  [management.ManagementStrategyFactory:create]: JMX enabled. Using
> > ManagedManagementStrategy.
> > [2012/04/24 14:29:11.283] INFO
> >  [management.DefaultManagementLifecycleStrategy:doStart]: StatisticsLevel
> > at All so enabling load p
> > erformance statistics
> > [2012/04/24 14:29:11.342] INFO
> >  [converter.AnnotationTypeConverterLoader:load]: Found 3 packages with 15
> > @Converter classes to loa
> > d
> > [2012/04/24 14:29:11.362] INFO
> >  [converter.DefaultTypeConverter:loadCoreTypeConverters]: Loaded 170 core
> > type converters (total 17
> > 0 type converters)
> > [2012/04/24 14:29:11.367] INFO
> >  [converter.AnnotationTypeConverterLoader:load]: Loaded 2 @Converter
> classes
> > [2012/04/24 14:29:11.373] INFO
> >  [converter.DefaultTypeConverter:loadTypeConverters]: Loaded additional 9
> > type converters (total 17
> > 9 type converters) in 0.010 seconds
> > [2012/04/24 14:29:11.511] INFO  [simpl.SimpleThreadPool:initialize]: Job
> > execution threads will use class loader of thread: org.ap
> > ache.camel.spring.Main.main()
> > [2012/04/24 14:29:11.527] INFO  [core.SchedulerSignalerImpl:<init>]:
> > Initialized Scheduler Signaller of type: class org.quartz.cor
> > e.SchedulerSignalerImpl
> > [2012/04/24 14:29:11.528] INFO  [core.QuartzScheduler:<init>]: Quartz
> > Scheduler v.1.8.5 created.
> > [2012/04/24 14:29:11.530] INFO  [simpl.RAMJobStore:initialize]:
> RAMJobStore
> > initialized.
> > [2012/04/24 14:29:11.531] INFO  [core.QuartzScheduler:initialize]:
> > Scheduler meta-data: Quartz Scheduler (v1.8.5) 'DefaultQuartzSc
> > heduler-camel-1' with instanceId 'NON_CLUSTERED'
> >  Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
> >  NOT STARTED.
> >  Currently in standby mode.
> >  Number of jobs executed: 0
> >  Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
> >  Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support
> > persistence. and is not clustered.
> >
> > [2012/04/24 14:29:11.532] INFO  [impl.StdSchedulerFactory:instantiate]:
> > Quartz scheduler 'DefaultQuartzScheduler-camel-1' initiali
> > zed from an externally provided properties instance.
> > [2012/04/24 14:29:11.533] INFO  [impl.StdSchedulerFactory:instantiate]:
> > Quartz scheduler version: 1.8.5
> > [2012/04/24 14:29:11.545] INFO
> >  [quartz.ScheduledRoutePolicy:scheduleRoute]: Scheduled trigger:
> > triggerGroup-route1.trigger-START-
> > route1 for action: START on route:
> > [2012/04/24 14:29:11.563] INFO
> >  [spring.SpringCamelContext:doStartOrResumeRouteConsumers]: Skipping
> > starting of route route1 as it
> > s configured with autoStartup=false
> > [2012/04/24 14:29:11.564] INFO  [quartz.QuartzComponent:startScheduler]:
> > Starting Quartz scheduler: DefaultQuartzScheduler-camel-1
> >
> > [2012/04/24 14:29:11.564] INFO  [core.QuartzScheduler:start]: Scheduler
> > DefaultQuartzScheduler-camel-1_$_NON_CLUSTERED started.
> > [2012/04/24 14:29:11.567] INFO  [spring.SpringCamelContext:start]: Total
> 1
> > routes, of which 0 is started.
> > [2012/04/24 14:29:11.568] INFO  [spring.SpringCamelContext:start]: Apache
> > Camel 2.9.2 (CamelContext: camel-1) started in 0.328 sec
> > onds
> > [2012/04/24 14:29:12.019] INFO
> >  [spring.SpringCamelContext:doStartOrResumeRouteConsumers]: Route: route1
> > started and consuming fro
> > m: Endpoint[http://razvoj.dev.interseek.com/test.txt]
> > [2012/04/24 14:29:13.207] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:13.227] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:13.237] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:13.247] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:13.257] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:13.267] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:13.277] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:13.287] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:13.297] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:13.307] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:13.317] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:13.327] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:13.337] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:13.347] INFO  [route1:info]: Just some small text file
> > ...LOTS MORE UNTIL I BREAK THE EXECUTION
> > [2012/04/24 14:29:24.048] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:24.050] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:24.052] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:24.054] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:24.056] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:24.058] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:24.060] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:24.062] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:24.064] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:24.066] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:24.067] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:24.070] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:24.072] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:24.073] INFO  [main.MainSupport$HangupInterceptor:run]:
> > Received hang up - stopping the main instance.
> > [2012/04/24 14:29:24.074] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:24.074] INFO  [main.MainSupport:doStop]: Apache Camel
> > 2.9.2 stopping
> > [2012/04/24 14:29:24.075] INFO  [spring.SpringCamelContext:doStop]:
> Apache
> > Camel 2.9.2 (CamelContext: camel-1) is shutting down
> > [2012/04/24 14:29:24.076] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:24.076] INFO
>  [impl.DefaultShutdownStrategy:doShutdown]:
> > Starting to graceful shutdown 1 routes (timeout 300 sec
> > onds)
> > [2012/04/24 14:29:24.078] INFO  [route1:info]: Just some small text file
> > [2012/04/24 14:29:24.079] INFO  [impl.DefaultShutdownStrategy:run]:
> Route:
> > route1 shutdown complete, was consuming from: Endpoint[
> > http://razvoj.dev.interseek.com/test.txt]
> > [2012/04/24 14:29:24.079] INFO
>  [impl.DefaultShutdownStrategy:doShutdown]:
> > Graceful shutdown of 1 routes completed in 0 seconds
> > [2012/04/24 14:29:24.081] INFO  [quartz.QuartzComponent:doStop]: There
> are
> > no more jobs registered, so shutting down Quartz schedu
> > ler: DefaultQuartzScheduler-camel-1
> > [2012/04/24 14:29:24.082] INFO  [core.QuartzScheduler:shutdown]:
> Scheduler
> > DefaultQuartzScheduler-camel-1_$_NON_CLUSTERED shutting
> >  down.
> > [2012/04/24 14:29:24.082] INFO  [core.QuartzScheduler:standby]: Scheduler
> > DefaultQuartzScheduler-camel-1_$_NON_CLUSTERED paused.
> > [2012/04/24 14:29:24.082] INFO  [core.QuartzScheduler:shutdown]:
> Scheduler
> > DefaultQuartzScheduler-camel-1_$_NON_CLUSTERED shutdown
> >  complete.
> > [2012/04/24 14:29:24.083] INFO  [impl.DefaultInflightRepository:doStop]:
> > Shutting down with no inflight exchanges.
> > [2012/04/24 14:29:24.084] INFO  [spring.SpringCamelContext:doStop]:
> Uptime:
> > 12.845 seconds
> > [2012/04/24 14:29:24.085] INFO  [spring.SpringCamelContext:doStop]:
> Apache
> > Camel 2.9.2 (CamelContext: camel-1) is shutdown in 0.00
> > 9 seconds
> >
> > The cron expression
> >
> > cronPolicy.setRouteStartTime("0 0/1 * * * ?");
> >
> > waits correctly on the first minute to start consuming, but then it
> prints
> > out the contents of the file just like the above example - every few
> > milliseconds.
> >
> > Is CronScheduledRoutePolicy meant for something different or is this a
> bug?
> >
> > Cheers,
> > borut
>
>
>
> --
> Claus Ibsen
> -----------------
> CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message