Quartz fails to delete a job, now what?
java, quartz-scheduler
Solution
- Yes, you're already doing it.
- The job is currently running.
If you need to delete a job while it's running make sure your job implements org.quartz.InterruptableJob. Then you may call `org.quartz.Scheduler.interrupt(JobKey)` to stop it while it's running.
Try adding a catch for general Exception after your SchedulerException (it's better exception handling and if you're not sure about the errors you may get it will help you).
Also keep in mind that when you build the quartz job, you can use `jobBuilder.storeDurably(false)`, which will cause your quartz job to be deleted automatically when there are no longer active trigger associated to it.
Problem
Given a Quartz job and the following command ``` boolean deleted = scheduler.deleteJob(event.getName(), "some group name") ``` Assuming `deleted` comes back as `false`, as i understand it, it means that from the stand point of JVM, the job is still there. With this 2 questions: - Is it possible to force delete a job? - What event prevents Quartz to delete a job? If exception is not thrown, is it safe to assume that job was not found? What would cause this? Isn't the only way for this to happen is for the job to be deleted on the first place? I am using ``` <dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz</artifactId> <version>1.8.0</version> </dependency> ``` Does this strike you as a correct way to handle things? Is my reasoning correct? ``` boolean deleted; try { deleted = scheduler.deleteJob(event.getName(), "some group name"); if (!deleted) { logger.warn("Quartz failed to delete the job!" + event.getName() + ". Job not found"); } } catch (SchedulerException e) { logger.error("There is an internal Scheduler error", e); } ```