Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to store Trigger with name: 'trigger1' and group: 'group1', because one already exists with this identification

Referring delete trigger in quartz

I am getting the same issue: Unable to store Trigger with name: 'schedulerJobTrigger' and group: 'group1', because one already exists with this identification.

So before I think of unscheduling the Job I have a Query:

Say I have 2 jobs.. details as follows: Job1 : Start Time Today @ 17:30 and repeat twice after every 5 minutes Job 2 :Start Time Today @ 17:37

So if I unschedule a job(which supposedly removes the Trigger) after it executed at 17:30 and execute the Job2 then how will the scheduler run the Job1 which needs to be run @17:35 and 17:40 respectively(that's the repetitions)

Thanks, Please help!

Before trying the above scenario, even if I schedule a new job with a different schedule @ scheduler.scheduleJob(job, trigger); it gives me the exception: Unable to store Trigger with name: 'schedulerJobTrigger' and group: 'group1', because one already exists with this identification.

like image 226
user2176576 Avatar asked Sep 30 '22 20:09

user2176576


1 Answers

Solved, checked if the same trigger exists if yes, created a new trigger instance..with a different identity and run the code.

boolean flag = scheduler.checkExists(trigger.getKey());
if (!flag)
{
    scheduler.start();
    scheduler.scheduleJob(job, trigger);
}
else
{
    Trigger trigger1 =TriggerBuilder.newTrigger().withIdentity("schedulerJobTrigger1", "group1").withSchedule(schedBuilder).build();;
    scheduler.start();
    scheduler.scheduleJob(job, trigger1);
}
like image 128
user2176576 Avatar answered Oct 18 '22 06:10

user2176576