My route builder has a route starts with a  cron job that executes every 5
minutes, but it never get kicked off by quartz scheduler and from the log
file, seems the job is removed because of routes shut down by the camel
context, here is what I did:
*1. the way I run camel in standalone mode:*
java MyMain appContext.xml
*2. MyMain class:*
public class MyMain extends RouteBuilder {
    public static void main(String... args)   {         
        try {
                org.apache.camel.spring.Main.main(args);
        }
        catch(Exception e) {            
                e.printStackTrace();
        }
    }
    public void configure()    {
    }
}
*3. appContext.xml defines a camel context:*
   <camelContext id="myCamelContext"
xmlns="http://camel.apache.org/schema/spring";>
         <packageScan>
            <package>com.mycompany.routes</package>
         .............................
*4. my route builder:*
public class MyCronJobRouteBuilder extends RouteBuilder {
   public void configure() {
      from("quartz://myGroup/myTimer?cron=0+0/5+*+*+*+?")
                .routeId("MyCronJobRoute}")
                .log(LoggingLevel.INFO, "My cron job started at 
${header.fireTime} ")
................................
   }
}

the "My cron job started at ${header.fireTime}" never get logged so the cron
job never started, from the log file, seems the route was created, scheduler
started and the job was added to scheduler too, but it was removed from the
scheduler when the DefaultCamelContext shuts down the route, anyone can help
me with a solution to prevent the camel context shut down the route and
remove the cron job? Thanks in advance ......

[                          main] QuartzScheduler                INFO  Quartz
Scheduler v.1.8.3 created.
[                          main] RAMJobStore                    INFO 
RAMJobStore initialized.
[                          main] QuartzScheduler                INFO 
Scheduler meta-data: Quartz Scheduler (v1.8.3) 'DefaultQuartzScheduler' 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.

[                          main] StdSchedulerFactory            INFO  Quartz
scheduler 'DefaultQuartzScheduler' initialized from default resource file in
Quartz package: 'quartz.properties'
[                          main] StdSchedulerFactory            INFO  Quartz
scheduler version: 1.8.3
[                          main] QuartzComponent                INFO 
Starting Quartz scheduler: DefaultQuartzScheduler
[                          main] QuartzScheduler                INFO 
Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.

[                          main] DefaultComponent               DEBUG
Creating endpoint uri=[quartz://myGroup/myTimer?cron=0+0%2F5+*+*+*+%3F],
path=[myGroup/myTimer], parameters=[{cron=0 0/5 * * * ?}]
[                          main] DefaultCamelContext            DEBUG
quartz://myGroup/myTimer?cron=0+0%2F5+*+*+*+%3F converted to endpoint:
Endpoint[quartz://myGroup/myTimer?cron=0+0%2F5+*+*+*+%3F] by component:
org.apache.camel.component.quartz.QuartzComponent@487c5f
[                          main] QuartzConsumer                 DEBUG
Starting consumer: Consumer[quartz://myGroup/myTimer?cron=0+0%2F5+*+*+*+%3F]
[                          main] QuartzEndpoint                 DEBUG Adding
consumer Instrumentation:route[UnitOfWork(Pipeline[[Channel[Log[My cron job
started at ${header.fireTime}, cron job expression -
quartz://myGroup/myTimer?cron=0+0+0/4+*+*+?]], Channel[BeanProcessor[bean: 
...................................................................

*[                          main] QuartzComponent                DEBUG
Adding job using trigger: *staleMeter/staleMeterDetectionTimer
[                          main] DefaultCamelContext            INFO  Route:
quartz:MyCronJobRoute started and consuming from:
Endpoint[quartz://myGroup/myTimer?cron=0+0%2F5+*+*+*+%3F]

...................................

[                          main] DefaultExecutorServiceStrategy DEBUG
ShutdownNow ExecutorService: java.util.concurrent.ThreadPoolExecutor@a84b47
[                          main] DefaultCamelContext            INFO  Apache
Camel 2.5.0 (CamelContext:myCamelContext) is shutting down
[                          main] DefaultShutdownStrategy        INFO 
Starting to graceful shutdown 1 routes (timeout 10 seconds)
[ Camel Thread 0 - ShutdownTask] QuartzComponent                DEBUG
Pausing job using trigger: myGroup/myTimer
*[ Camel Thread 0 - ShutdownTask] QuartzEndpoint                 DEBUG
Removing consumer* Instrumentation:route[UnitOfWork(Pipeline[[Channel[Log[My
cron job started at ${header.fireTime}]], 
...................

--
View this message in context: 
http://camel.465427.n5.nabble.com/Cron-job-removed-from-quartz-scheduler-by-DefaultCamelContext-tp5474330p5474330.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to