|
|
|
Thanks for the reply. I didn't notice the comments before and sorry for the late response.
I created a testcase. This is the implementation of DumbJob. =============================================================== package com.test.quartz; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import org.quartz.StatefulJob; public class DumbJob implements StatefulJob { private boolean running = false; /* (non-Javadoc) * @see org.quartz.Job#execute(org.quartz.JobExecutionContext) */ public void execute(JobExecutionContext context) throws JobExecutionException { running = true; System.out.println("Start executing"); while (running) { System.out.println("running..."); try { Thread.sleep(10 * 1000L); } catch (InterruptedException ie) { } } System.out.println("Job aborted"); } /** * To be called to stop the job. * * @throws JobExecutionException */ public void abort() throws JobExecutionException { System.out.println("Trying to abort..."); running = false; } } ============================================================ This is jobs.xml ============================================================ <?xml version="1.0" encoding="utf-8"?> <!-- <quartz xmlns="http://www.quartzscheduler.org/ns/quartz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.quartzscheduler.org/ns/quartz http://www.quartzscheduler.org/ns/quartz/job_scheduling_data_1_1.xsd" version="1.1"> --> <quartz> <job> <job-detail> <name>job1</name> <group>group1</group> <job-class>com.test.quartz.DumbJob</job-class> <durability>true</durability> <volatility>false</volatility> <recover>true</recover> </job-detail> <trigger> <simple> <name>trigger1</name> <group>group1</group> </simple> </trigger> </job> </quartz> ============================================================ This is part of the code to start/stop scheduler: ============================================================ lg.info("------- Initializing -------------------"); Scheduler sched = sf.getScheduler(); lg.info("------- Initialization Complete -----------"); sched.start(); lg.info("------- Started Scheduler -----------------"); lg.info("------- Waiting 30 Secs... -----------------------"); try { Thread.sleep(30L * 1000L); // wait 30 seconds to show jobs // executing... } catch (Exception e) { } lg.info("------- To stop Job... -----------------------"); List jobs = sched.getCurrentlyExecutingJobs(); Iterator iter = jobs.iterator(); while (iter.hasNext()) { JobExecutionContext jec = (JobExecutionContext) iter.next(); Job currentJob = jec.getJobInstance(); if (currentJob instanceof DumbJob) { DumbJob dumbJob = (DumbJob) currentJob; dumbJob.abort(); } } lg.info("------- Waiting 20 Secs... -----------------------"); try { Thread.sleep(20L * 1000L); // executing... } catch (Exception e) { } lg.info("------- Shutting Down ---------------------"); sched.shutdown(); lg.info("------- Shutdown Complete -----------------"); SchedulerMetaData metaData = sched.getMetaData(); lg.info("Executed " + metaData.numJobsExecuted() + " jobs."); ===================================================================== From the log, I can see that DumbJob was called twice and it will print "Executed 2 jobs" in the end. The problem only exists if I use jdbc job store and before running the program, I deleted content in all quartz database tables. Please let me know if you need more info. Thanks, Zhe Hi,
I have the same problem with Quartz 1.4.0. Has anyone solved this problem of running 2 jobs instead of one? Could anyone help me out !!! could some one in Quartz please give some suggestion. We have this problem in quartz 1.4.1 as well. Can we expect a fix soon?
I have the same problem in quartz 1.4.2. Is there any known solution to fix this? Is it planned to be fixed anytime soon?
I didn't quiet understand Dev's comment. Does it mean that I need to run Quartz in cluster in order to fix this problem? Could you please point me to information on how to do it? I've tried and tried to reproduce this, including with the example code, and cannot get it to run more than the one job.
| ||||||||||||||||||||||||||||||||||||||||||||||
Can you post the source of the DubJob classe(s)?
Or at least describe in detail what the jobs do, and what abort() does?
thanks,
james
(Also a complete test application for replicating the problem would be good).