Commits

jhouse  committed bc52ca4

QUARTZ-432 - Having a TriggerListener veto a StatefulJob strands the Trigger in BLOCKED state

git-svn-id: http://svn.opensymphony.com/svn/quartz/trunk@65169f7d36a-ea1c-0410-88ea-9fd03e4c9665

  • Participants
  • Parent commits 527580e

Comments (0)

Files changed (3)

File src/java/org/quartz/core/JobRunShell.java

                 }
             } catch(VetoedException ve) {
                 try {
+                    int instCode = trigger.executionComplete(jec, null);
+                    try {
+                        qs.notifyJobStoreJobVetoed(schdCtxt, trigger, jobDetail, instCode);
+                    }
+                    catch(JobPersistenceException jpe) {
+                        vetoedJobRetryLoop(trigger, jobDetail, instCode);
+                    }
                     complete(true);
                 } catch (SchedulerException se) {
                     qs.notifySchedulerListenersError("Error during veto of Job ("
             JobDetail jobDetail, int instCode) {
         while (!shutdownRequested) {
             try {
-                Thread.sleep(5 * 1000l); // retry every 5 seconds (the db
+                Thread.sleep(5 * 1000L); // retry every 5 seconds (the db
                 // connection must be failed)
                 qs.notifyJobStoreJobComplete(schdCtxt, trigger, jobDetail,
                         instCode);
         return false;
     }
 
-    
+    public boolean vetoedJobRetryLoop(Trigger trigger, JobDetail jobDetail, int instCode) {
+        while (!shutdownRequested) {
+            try {
+                Thread.sleep(5 * 1000L); // retry every 5 seconds (the db
+                // connection must be failed)
+                qs.notifyJobStoreJobVetoed(schdCtxt, trigger, jobDetail, instCode);
+                return true;
+            } catch (JobPersistenceException jpe) {
+                qs.notifySchedulerListenersError(
+                        "An error occured while marking executed job vetoed. job= '"
+                                + jobDetail.getFullName() + "'", jpe);
+            } catch (InterruptedException ignore) {
+            }
+        }
+        return false;
+    }
+
     class VetoedException extends Exception {
         public VetoedException() {
         }

File src/java/org/quartz/core/QuartzScheduler.java

                 instCode);
     }
 
+    protected void notifyJobStoreJobVetoed(SchedulingContext ctxt,
+            Trigger trigger, JobDetail detail, int instCode)
+        throws JobPersistenceException {
+
+        resources.getJobStore().triggeredJobComplete(ctxt, trigger, detail, instCode);
+    }
+
     protected void notifySchedulerThread() {
         if (isSignalOnSchedulingChange()) {
             schedThread.signalSchedulingChange();

File src/java/org/quartz/spi/JobStore.java

     /**
      * <p>
      * Inform the <code>JobStore</code> that the scheduler has completed the
-     * firing of the given <code>Trigger</code> (and the execution its
-     * associated <code>Job</code>), and that the <code>{@link org.quartz.JobDataMap}</code>
+     * firing of the given <code>Trigger</code> (and the execution of its
+     * associated <code>Job</code> completed, threw an exception, or was vetoed),
+     * and that the <code>{@link org.quartz.JobDataMap}</code>
      * in the given <code>JobDetail</code> should be updated if the <code>Job</code>
      * is stateful.
      * </p>