Suren Raju
Suren Raju

Reputation: 3070

Why Quartz scheduler's unscheduleJob is deleting both trigger and job detail?

Im trying to execute the following quartz scheduler code in the a cluster environment.

scheduler.unscheduleJob("genericJobTrigger", "DEFAULT");

where as

Scheduler scheduler = (Scheduler) context.getBean("scheduler");
JobDetail genericJob = (JobDetail) context.getBean("genericJob");
CronTrigger genericJobTrigger = (CronTrigger) context.getBean("genericJobTrigger");

Above piece of code is deleting entries from trigger and job detail. It supposed to remove only trigger right?

Why Quartz scheduler's unscheduleJob is deleting both trigger and job detail?

Upvotes: 0

Views: 4168

Answers (2)

Whenever you are creating an object of JobDetail then set storeDurably(), refer the below example:

return JobBuilder.newJob(ScheduledJob.class)
                .setJobData(jobDataMap)
                .withDescription("job executes at specified frequency")
                .withIdentity(UUID.randomUUID().toString(), "email-jobs")
                .storeDurably() //This will not allow to delete automatially
                .build();

Also you can verify it by checking the value of IS_DURABLE column in jobDetails table.

Upvotes: 0

Suren Raju
Suren Raju

Reputation: 3070

durability is set true to Jobs to avoid deleting the JOBS when Triggers are deleted.

Upvotes: 3

Related Questions