即使删除了 Quartz 作业,它们仍然会出现。你知道为什么吗?
我看到调度程序返回相同的作业 (scheduler.getCurrentlyExecutingJobs()),即使在删除它之后 (scheduler.deleteJob(jobExCntxt.getJobDetail().getName(), jobExCntxt.getJobDetail().getGroup()))。我做的事正确吗?我想永远删除该作业和相关线程。这可能吗?
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();
}
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();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过中断()工作? deleteJob() 仅从作业存储中删除作业。
Have you tried interrupt() the job? deleteJob() only removes the job from the job store.