即使删除了Quartz作业,它们也会显示出来。你知道为什么吗?

时间:2011-03-29 14:47:02

标签: java quartz-scheduler

我看到调度程序甚至在删除它之后返回相同的作业(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();
        }

1 个答案:

答案 0 :(得分:0)

你尝试过中断()工作吗? deleteJob()仅从作业存储中删除作业。