public function executeJob(Job $job) { $worker = $this->container->get($job->getName()); if (!$worker instanceof Worker) { throw new InvalidWorkerException("The worker {$job->getName()} is not an instance of " . Worker::class); } $worker->execute($job->getArguments()); }
public function delete(Job $job) { if (!$job instanceof BeanstalkJob) { throw new WrongJobException('Beanstalk manager can only delete beanstalk jobs'); } try { $this->pheanstalk->delete($job->getId()); } catch (ServerException $e) { throw new NoSuchJobException("Error deleting job", 0, $e); } }
public function delete(Job $job) { if (!$job instanceof ResqueJob) { throw new WrongJobException('Resque queue manager can only delete resque jobs'); } if (!$job->isFutureJob()) { throw new NoSuchJobException('Resque queue manager can only delete future jobs'); } if ($this->debug) { return; } if (\ResqueScheduler::removeDelayedJobFromTimestamp($job->getWhen(), $job->getQueue(), $job->getClass(), $job->getResqueArguments(), $job->isTrackStatus()) < 1) { throw new NoSuchJobException('No jobs were found'); } }
/** * Remove a job, you should call this when you have finished processing a job * * @param $job * @throws WrongJobException * @throws NoSuchJobException */ public function delete(Job $job) { $this->info('Deleting job', ['name' => $job->getName()]); }
/** * Called when a job failed * * @param Job $job * @param \Exception $exception */ protected function failedJob(Job $job, \Exception $exception) { if ($this->logger) { $context = ['name' => $job->getName(), 'arguments' => $job->getArguments(), 'message' => $exception->getMessage(), 'retryable' => !$exception instanceof UnrecoverableJobException]; if ($p = $exception->getPrevious()) { $context['cause'] = $p->getMessage(); } $this->logger->error('Job failed', $context); } $this->eventDispatcher && $this->eventDispatcher->dispatch(self::JOB_FAILED_EVENT, new FailedJobEvent($job, $exception)); }