views:

86

answers:

1

Hello

I have Quartz coded as follows and the first job runs perfectly:

JobDetail jd = null;
CronTrigger ct = null;   
jd = new JobDetail("Job1", "Group1",  Job1.class);
ct = new CronTrigger("cronTrigger1","Group1","0/5 * * * * ?");
scheduler.scheduleJob(jd, ct);
jd = new JobDetail("Job2", "Group2",  Job2.class);
ct = new CronTrigger("cronTrigger2","Group2","0/20 * * * * ?");
scheduler.scheduleJob(jd, ct);

But I'm finding that Job2, which is a completely separate job to Job1, will not execute.

The scheduler is started using a listener in Java. I've also tried using scheduler.addJob(jd, true); but nothing changes. I'm running Java through a JVM on windows 7.

Any ideas?

Thanks

Mr Morgan.

+1  A: 

How do you know the job does not run? If you substitute Job1.class for Job2.class, does it still fail? When you swap order in which they're added to scheduler, or only leave Job2? Or if you strip down Job2 to only print a message to console?

I suspect Job2 execution dies with an exception.

Konrad Garus
I've tried changing the ordering of the jobs and have tried numerous debug messages throughout both. but only job 1 runs.
Mr Morgan
So there must be a bug within Job2. Wrap everything in execute() in try { ... } catch(Throwable t) { t.printStackTrace(); } and see what happens.
Konrad Garus
Bad logic on my part. Mea culpa! And now to sort out the cron timings so that one job runs on the hour and the other on the half hour.
Mr Morgan
"30 * * * * ?" (1:30, 2:30, 3:30), "0 * * * * ?" (1:00, 2:00, 3:00), "*/30 * * * * ?" (1:00, 1:30, 2:00, 2:30), "15,45 * * * * ?" (1:15, 1:45, 2:15)
Konrad Garus
If "30 * * * * ?" runs the job half past every hour, does "0 * * * * ?" run on the hour? Thanks.
Mr Morgan
Err, sorry for the typo. Actually, that should be "0 30 * * * ?" and "0 0 * * * ?". See also http://www.quartz-scheduler.org/docs/tutorial/TutorialLesson06.html and http://en.wikipedia.org/wiki/CRON_expression or just Google cron expression.
Konrad Garus
@Konrad Garus: Many thanks. Would you have any idea about: http://stackoverflow.com/questions/3185221/running-a-quartz-job-with-java-class-name-stored-in-database
Mr Morgan