public function testCreateJob() { $job = new Job($this->job_name, $this->job_data); $this->assertNull($job->getId()); $this->assertEquals($this->job_name, $job->getClassName()); $this->assertEquals($this->job_data, $job->getArguments()); $this->assertLessThanOrEqual(new DateTime(), $job->getCreatedAt()); }
/** * @param Job $job */ protected function executeJob($job) { $this->log('Executing job ' . $job->getId()); if ($this->runner->runJob($job)) { $this->queue->delete($job); } else { $this->log("Job failed"); if ($this->queue->countReserves($job) < 3) { $this->log("Putting back in queue"); $this->queue->release($job); } else { $this->log("Putting job on hold"); $this->queue->bury($job); } } }
public function countReserves(Job $job) { $stats = $this->pheanstalk->statsJob($job->getId()); return $stats->reserves; }