Process a single job.

@param Resque_Job $job The job to be processed.
168803
public function perform(Resque_Job $job)
    {
        $startTime = microtime(true);
        try {
            Resque_Event::trigger('afterFork', $job);
            $job->perform();
            $this->log(array('message' => 'done ID:' . $job->payload['id'], 'data' => array('type' => 'done', 'job_id' => $job->payload['id'], 'time' => round(microtime(true) - $startTime, 3) * 1000)), self::LOG_TYPE_INFO);
        } catch (Exception $e) {
            $this->log(array('message' => $job . ' failed: ' . $e->getMessage(), 'data' => array('type' => 'fail', 'log' => $e->getMessage(), 'job_id' => $job->payload['id'], 'time' => round(microtime(true) - $startTime, 3) * 1000)), self::LOG_TYPE_ERROR);
            $job->fail($e);
            return;
        }

        $job->updateStatus(Resque_Job_Status::STATUS_COMPLETE);
    }
82947
public function deleteReserved($queue, $job)
    {
        $this->getConnection()->zRem($this->getQueue($queue) . ':reserved', $job);
    }
457393
protected function finishJob(Job $job, bool $internal): void
    {
        if ($this->logger) {
            $this->logger->info('Finished a job.', [
                'name' => $job->getName(),
                'arguments' => $job->getArguments(),
            ]);
        }
        if ($this->eventDispatcher) {
            $this->eventDispatcher->dispatch(self::JOB_FINISHED_EVENT, new FinishedJobEvent($job, $internal));
        }
        if ($this->triggerBatchEvents) {
            $this->finishBatch(new JobBatch([], [$job]));
        }
    }
1010220
public function deleteReserved($queue, $job)
    {
        parent::deleteReserved($queue, $job);

        $this->event($this->getQueue($queue), new JobDeleted($job, $job->getReservedJob()));
    }
484193
protected function doJob(AbstractJob $job)
    {
        $this->validateJobParams($job);

        try {
            $resultData['response'] = $this->sendMessage($job);
        } catch (\Exception $ex) {
            throw new ResultException(ResultException::ERROR_TRANSPORT);
        }

        throw new ResultException(ResultException::R_SUCCESS, $resultData);
    }
1315085
public function process( $connection, Job $job, $maxTries = 0, $delay = 0 )
	{
		if ( $maxTries > 0 && $job->attempts() > $maxTries )
			return $this->logFailedJob( $connection, $job );

		try
		{
			$this->raiseBeforeJobEvent( $connection, $job );

			// First we will fire off the job. Once it is done we will see if it will be
			// automatically deleted after processing and if so we'll fire the delete
			// method on the job. Otherwise, we will just keep on running our jobs.
			$job->fire();

			$this->raiseAfterJobEvent( $connection, $job );

			return ['job' => $job, 'failed' => false];
		}
		catch ( Exception $e )
		{
			$this->handleJobException( $connection, $job, $delay, $e );
		}
		catch ( Throwable $e )
		{
			$this->handleJobException( $connection, $job, $delay, $e );
		}

		return null;
	}
850874
private function runJob(JobInterface $job)
    {
        $this->log(LogLevel::DEBUG, 'Job starting');
        $status = $this->executor->execute($job);
        $this->log(LogLevel::DEBUG, 'Job finished');

        return $status;
    }
292451
private function setWorkingOn(Job $job)
    {
        $this->setTask(
            [
                'queue' => $job->getQueue(),
                'run_at' => strftime('%a %b %d %H:%M:%S %Z %Y'),
                'payload' => $job->getPayload(),
            ]
        );

        $this->current_job = $job;
        $job->setWorker($this->getId());
        $this->job_manager->updateStatus($job, JobManager::STATUS_RUNNING);
    }
1128411
public function enqueue(Job $job): void
    {
        $this->adapter->enqueue($job);
        $this->updateStatus($job, self::STATUS_WAITING);
    }
35859
public function deleteReserved($queue, $job)
    {
        $this->getConnection()->zrem($this->getQueue($queue).':reserved', $job);
    }
1059986
protected function raiseFailedJobEvent( Job $job )
	{
		$data = json_decode( $job->getRawBody(), true );

		Hooks::trigger( 'queue.job.failed', compact( 'job', 'data' ) );
	}
740909
public function push(Job $job, $queueName = '')
    {
        if (!isset($this->queues[$queueName])) {
            $this->queues[$queueName] = [];
        }

        $this->queues[$queueName][] = $job;

        return Queue::QUEUED;

    }
4354
private function runAsChild(Job $job): void
    {
        $status = sprintf('Processing ID: %s in %s', $job->getId(), $job->getQueue());
        $this->updateProcLine($status);

        $this->log->info($status);

        $this->job_manager->run($job);

        if ($this->child === 0) {
            exit(0);
        }
    }
660533
public function run(Job $job)
    {
        $this->getEventManager()->trigger('afterFork', $job);

        try {
            $jobInstance = $this->strategy->getJobInstance($job->getClass());

            $this->getEventManager()->trigger('beforePerform', $job);

            if (method_exists($jobInstance, 'setUp')) {
                $jobInstance->setUp();
            }

            $args = $job->getArgs();

            $jobInstance(...$args);

            if (method_exists($jobInstance, 'tearDown')) {
                $jobInstance->tearDown();
            }

            $this->getEventManager()->trigger('afterPerform', $job);
        } /** @noinspection PhpRedundantCatchClauseInspection */ catch (DontPerform $e) {
            $this->log->debug(sprintf('Job %s triggered a DontPerform', $job->getId()));
            // Don't Perform this job triggered
        } catch (Throwable $e) {
            $this->log->error(
                sprintf(
                    '%s failed %s',
                    $job->getId(),
                    $e->getMessage()
                ),
                ['exception' => $e, 'job' => $job]
            );

            $this->failJob($job, $e);

            return;
        }

        $this->updateStatus($job, self::STATUS_COMPLETE);
    }
251184
protected function doJob(AbstractJob $job)
    {
        $this->validateJobParams($job);

        try {

            $response = $this->sendMail($job);
            $resultData['response'] = $response;

        } catch (\Exception $ex) {
            throw new ResultException(ResultException::RETRY_TRANSPORT_ERROR);
        }

        if(!$resultData['response']['success']){
            throw new ResultException(ResultException::R_FAILURE, $resultData);
        }

        throw new ResultException(ResultException::R_SUCCESS, $resultData);
    }
1098953
protected function processIteration(array &$job)
    {
        try {
            $handlers = $this->getHandlers();
            $callback = Handler::get($handlers, $job['id'], 'process');
            call_user_func_array($callback, array(&$job));
        } catch (Exception $ex) {
            $job['status'] = false;
            $job['errors']++;
        }
    }
463876
public function bury(Job $job)
    {
        $this->pheanstalk->bury($job);

        $this->logJob($job->getId(), 'Job buried');
    }