Quartz jobs are showing up even after deleting them. Do you know why?
I am seeing the scheduler returns the same job (scheduler.getCurrentlyExecutingJobs()) even after deleting it (scheduler.deleteJob(jobExCntxt.getJobDetail().getName(), jobExCntxt.getJobDetail().getGroup())). Am I doing the right thing? I wanted to remove that job and associated threads forever. Is that possible?
try {
List<JobExecutionContext> jobExCntxts = scheduler.getCurrentlyExecutingJobs();
if(jobExCntxts != null){
for(JobExecutionContext jobExCntxt: jobExCntxts){
if(jobExCntxt != null){
Date triggerTime = DateUtils.addMinutes(jobExCntxt.getTrigger().getPreviousFireTime(), 1);
if(triggerTime.before(Calendar.getInstance().getTime())){
开发者_如何学运维 System.out.println("Deleting a long living job !");
System.out.println("Delete return = " + scheduler.deleteJob(jobExCntxt.getJobDetail().getName(),
jobExCntxt.getJobDetail().getGroup()));
}
}
}
}
} catch (SchedulerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Have you tried interrupt() the job? deleteJob() only removes the job from the job store.
精彩评论