如何在 Quartz JDBC Store 中删除作业? [英] How to remove job in Quartz JDBC Store?
本文介绍了如何在 Quartz JDBC Store 中删除作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写这个方法是为了从 Quartz JDBC 中删除一个作业
I wrote this method to remove a job from Quartz JDBC
public boolean removeJob(String jobName) {
try {
JobKey jobKey = JobKey.jobKey(jobName);
try {
Scheduler sched = schedulerFactoryBean.getScheduler();
logger.info("RESULT: " + sched.deleteJob(jobKey));
} catch (Exception e) {
throw new RuntimeException(e);
}
return true;
} catch (Exception ex) {
logger.error(ex.getMessage());
return false;
}
}
deleteJob
总是返回 false
.因此,该作业不会从 mysql 的 JDBC 表中删除.我究竟做错了什么.我只想从调度程序中完全删除此作业
deleteJob
is always returning false
. So the job is not getting removed from the JDBC tables in mysql. What am I doing wrong. I only want to completely remove this job from the scheduler
推荐答案
您是否在创建作业时定义了作业组?然后你可能需要调用jobKey(jobName, group)
.您还可以使用 scheduler.checkExists(jobKey)
方法检查作业是否存在,这将有助于调试.
Have you defined a job group during job creation? Then you may need to call jobKey(jobName, group)
. You can also check if job exists with scheduler.checkExists(jobKey)
method which will be good for debugging.
JobKey jobKey = jobKey(jobName, group);
if (scheduler.checkExists(jobKey)) {
logger.info("job found with key: {}", jobKey);
scheduler.deleteJob(jobKey);
}
这篇关于如何在 Quartz JDBC Store 中删除作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文