Problem:
Exception Caught: Quartz.ObjectAlreadyExistsException: Unable to store Job with name: 'updateMyStuff' and group: 'DEFAULT', because one already exists with this identification.
Code:
// construct job info for every 10 seconds
JobDetail = jobDetail = new JobDetail("updateMyStuff", null, typeof(UpdateMyOneMethod));
trig = new CronTrigger();
trig.CronExpression = new CronExpression("0/10 * * * * ?");
trig.Name = " updateStuff ";
sched.ScheduleJob(jobDetail, trig);
// job for every day 12:00 am
jobDetail = new JobDetail("updateMyStuff", null, typeof(UpdateMyOtherMethod));
trig = new CronTrigger();
trig.CronExpression = new CronExpression("0 0 0 * * ?");
trig.Name = "updateStuff";
sched.ScheduleJob(jobDetail, trig);
Solution:
I was clearly very tired and not paying attention and made a miserable copy/paste error. Make sure the JobDetail has a unique name and same with the trigger! Fixed Code, changes bolded:
// construct job info for every 10 seconds
JobDetail = jobDetail = new JobDetail("updateMyStuff", null, typeof(UpdateMyOneMethod));
trig = new CronTrigger();
trig.CronExpression = new CronExpression("0/10 * * * * ?");
trig.Name = " updateStuff ";
sched.ScheduleJob(jobDetail, trig);
// job for every day 12:00 am
jobDetail = new JobDetail("updateMyOtherStuff", null, typeof(UpdateMyOtherMethod));
trig = new CronTrigger();
trig.CronExpression = new CronExpression("0 0 0 * * ?");
trig.Name = "updateOtherStuff";
sched.ScheduleJob(jobDetail, trig);
No comments:
Post a Comment