Skip to content

Commit

Permalink
FIX Ensure restarting jobs triggers on queue
Browse files Browse the repository at this point in the history
- Make sure that when a job is resumed it registers it against the queueHandler
  instead of just within the Descriptor class
  • Loading branch information
Marcus Nyeholt committed May 14, 2015
1 parent 98789f8 commit aaf60b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion code/dataobjects/QueuedJobDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function resume() {
$this->JobStatus = QueuedJob::STATUS_WAIT;
$this->ResumeCounts++;
$this->write();
$this->activateOnQueue();
singleton('QueuedJobService')->startJob($this);
}
}

Expand Down
15 changes: 12 additions & 3 deletions code/services/QueuedJobService.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,25 @@ public function queueJob(QueuedJob $job, $startAfter = null, $userId = null, $qu

$jobDescriptor->write();

$this->startJob($jobDescriptor, $startAfter);

return $jobDescriptor->ID;
}

/**
* Start a job (or however the queue handler determines it should be started)
*
* @param JobDescriptor $jobDescriptor
* @param date $startAfter
*/
public function startJob($jobDescriptor, $startAfter = null) {
if ($startAfter && strtotime($startAfter) > time()) {
$this->queueHandler->scheduleJob($jobDescriptor, $startAfter);
} else {
// immediately start it on the queue, however that works
$this->queueHandler->startJobOnQueue($jobDescriptor);
}

return $jobDescriptor->ID;
}


/**
* Copies data from a job into a descriptor for persisting
Expand Down

0 comments on commit aaf60b6

Please sign in to comment.