/**
  * @param Job $job
  */
 public function handleFailedJob(Job $job)
 {
     $stats = $job->stats();
     $normalizedTries = ($stats['reserves'] - 1) % $this->config->getMaxTries() + 1;
     if ($normalizedTries >= $this->config->getMaxTries()) {
         $job->bury($stats['pri']);
         $this->logger->warning('Job exceeded maximum tries, burying', ['job' => $job]);
     } else {
         $delay = $this->config->getDefaultFailureDelay() * $normalizedTries;
         $job->release($stats['pri'], $delay);
         $this->logger->notice('Releasing job with delay', ['job' => $job, 'delay' => $delay]);
     }
 }
Example #2
0
 public function testExecute_delegatesToCommand()
 {
     $this->commandMock->expects($this->once())->method('execute')->willReturn(true);
     $this->assertTrue($this->job->execute());
 }