Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running two jobs with Quartz in Java

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.

like image 675
Mr Morgan Avatar asked Nov 14 '22 09:11

Mr Morgan


1 Answers

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.

like image 141
Konrad Garus Avatar answered Dec 16 '22 20:12

Konrad Garus