问题
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 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
回答1:
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);
}
来源:https://stackoverflow.com/questions/53622605/how-to-remove-job-in-quartz-jdbc-store