James Raitsev
James Raitsev

Reputation: 96541

Managing quartz jobs, deleting

Consider the following sequence of events. Using quartz 1.8.0

    <dependency>
        <groupId>org.quartz-scheduler</groupId>
        <artifactId>quartz</artifactId>
        <version>1.8.0</version>
    </dependency>

I schedule a job to be executed in the future

     job.setGroup(MY_GROUP);
     Date date = scheduler.scheduleJob(job, trigger);    // Valid date received

Job executes as expected.

I then try to delete the job by running

     boolean unscheduled = scheduler.deleteJob(event.getName(), MY_GROUP); // Always false

Attempt to delete the job always results in **false**

If i let the application to run past the time it was scheduled to execute, after having failed to delete it, it ... does not run (as if it was deleted successfully)

What could explain such a behavior? How can i know what is scheduled in quartz as part of the group?

EDIT:

Trigger is set as:

        SimpleTrigger trigger = new SimpleTrigger();
        trigger.setStartTime(new Date(event.getStartTime().inMillis()));
        trigger.setName("trigger" + event.getTriggerName());
        trigger.setRepeatInterval(event.getFrequency());
        trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);

Upvotes: 0

Views: 2599

Answers (1)

Zim-Zam O&#39;Pootertoot
Zim-Zam O&#39;Pootertoot

Reputation: 18158

What trigger are you using? If you haven't specified that the trigger should fire multiple times e.g. on a recurring interval, then it will only fire once and will then be discarded; if your job detail isn't durable then the scheduler will automatically remove it once no more triggers point to it.

Upvotes: 1

Related Questions