记录失败任务
@param JobFailed $event
544797
protected function logFailedJob(JobFailed $event)
    {
        $this->app['queue.failer']->log(
            $event->connector, $event->job->getQueue(),
            $event->job->getRawBody(), $event->exception
        );
    }
573898
public function failed(JobInterface $job)
    {
        $this->checkConnected();
        $this->client->nack($job->getId());
    }
944302
protected function raiseFailedJobEvent(Job $job, $e)
    {
        $this->getEventsManager()->fire('listener:jobFailed', $this, [$job, $e]);
    }
244824
@MainThread
    private void handleEventFailure(Event event, EventFailure failure) {
        if (!activeEvents.contains(event)) {
            Utils.logE(event.getKey(), "Cannot send failure callback of finished event");
            return;
        }

        scheduleFailureCallbacks(event, failure);
        executeTasks(false);
    }
1285437
protected function displayFailedJobs(array $jobs)
    {
        $table = new Table();
        $table->setHeader($this->headers);
        $table->setRows($jobs);

        $this->table($table);
    }
1129326
public function delete(Job $job)
    {
        $result = false;
        try {
            $res = $this->_queue->deleteMessage($job->getInstance()->getReceiptHandle());
            $result = $res->isSucceed();
        } catch (\Exception $e) {
            $this->eventsManager->fire('listener:logger', $this, '删除Queue消息失败:' . $e->getMessage());
        } finally {
            return $result;
        }
    }
813729
public static function handle($connectionName, $job, $e = null)
    {
        $job->markAsFailed();

        if ($job->isDeleted()) {
            return;
        }

        try {
            // If the job has failed, we will delete it, call the "failed" method and then call
            // an event indicating the job has failed so it can be logged if needed. This is
            // to allow every developer to better keep monitor of their failed queue jobs.
            $job->delete();

            $job->failed($e);

        } finally {
        }
    }
272706
protected function raiseFailedJobEvent($connection, Job $job)
    {
        if (isset($this->events)) {
            $this->events->dispatch('nova.queue.failed', array($connection, $job));
        }
    }
1309161
protected function registerFailedJobsListener()
    {
        if (!in_array($this->app->environment(), config('nodes.bugsnag.notify_release_stages', []))) {
            return;
        }

        $shouldReport = config('nodes.bugsnag.report_failed_jobs');

        if ($shouldReport) {
            Queue::failing(function (JobFailed $event) {
                $exception = $event->exception;
                $meta = [
                    'job' => [
                        'name'     => $event->job->getName(),
                        'queue'    => $event->job->getQueue(),
                        'raw_body' => $event->job->getRawBody(),
                    ],
                    'connection' => [
                        'name' => $event->connectionName,
                    ],
                ];

                app('nodes.bugsnag')->notifyException($exception, function (\Bugsnag\Report $report) use ($meta) {
                    $report->setMetaData($meta, true);
                });
            });
        }
    }
482248
protected function writeOutput(Job $job, $failed)
	{
		if ($failed)
		{
			$this->output->writeln('<error>Failed:</error> '.$job->getName());
		}
		else
		{
			$this->output->writeln('<info>Processed:</info> '.$job->getName());
		}
	}
843580
public function process($connector, Job $job, $maxTries = 0, $delay = 0)
    {
        try {
            $this->event->trigger(new JobProcessing($connector, $job));

            $this->markJobAsFailedIfAlreadyExceedsMaxAttempts(
                $connector, $job, (int) $maxTries
            );

            $job->fire();

            $this->event->trigger(new JobProcessed($connector, $job));
        } catch (Exception | Throwable $e) {
            try {
                if (!$job->hasFailed()) {
                    $this->markJobAsFailedIfWillExceedMaxAttempts($connector, $job, (int) $maxTries, $e);
                }

                $this->event->trigger(new JobExceptionOccurred($connector, $job, $e));
            } finally {
                if (!$job->isDeleted() && !$job->isReleased() && !$job->hasFailed()) {
                    $job->release($delay);
                }
            }

            throw $e;
        }
    }
49109
protected function handle($event): void
    {
        $method = $this->getApplyMethod($event);

        if (!method_exists($this, $method)) {
            return;
        }

        $this->$method($event);
    }
1348506
public function fail($exception = null)
    {
        if ($this->job) {
            FailingJob::handle($this->job->getConnectionName(), $this->job, $exception);
        }
    }
277760
public function messageConsumptionFailed(MessageConsumptionFailed $event)
    {
        $this->logger->log(
            $this->logLevel,
            $this->logMessage,
            [
                'exception' => $event->exception(),
                'message' => $event->message()
            ]
        );
    }
1343252
public function perform(Job $job)
    {
        try {
            Event::trigger('afterFork', $job);
            $job->perform();
        } catch(Exception $e) {
            $this->log($job . ' failed: ' . $e->getMessage());
            $job->fail($e);
            return;
        }

        $job->updateStatus(Status::STATUS_COMPLETE);
        $this->log('done ' . $job);
    }
895858
public function executeJob(Job $job, int $retryLimit = 0): void
    {
        // This is here so that if executeJob is called with out startBatch the events will still be called
        $this->triggerBatchEvents = !$this->batchStarted;
        if ($this->triggerBatchEvents) {
            $this->startBatch(new JobBatch([$job]));
        }

        $internal = false;

        if ($this->logger) {
            $this->logger->debug('Start a job.', [
                'name' => $job->getName(),
                'arguments' => $job->getArguments(),
            ]);
        }

        try {
            $worker = $this->workersMap->get($job->getName());
            if (!$worker instanceof Worker) {
                throw new InvalidWorkerException("The worker {$job->getName()} is not an instance of ".Worker::class);
            }
            $internal = $worker instanceof InternalWorker;
            if ($this->eventDispatcher) {
                $this->eventDispatcher->dispatch(self::JOB_START_EVENT, new StartJobEvent($job, $internal));
            }
            $worker->execute($job->getArguments());
        } catch (NotFoundExceptionInterface $e) {
            $unrecoverable = new UnrecoverableJobException("Missing worker {$job->getName()}", 0, $e);
            $this->failedJob($job, $unrecoverable, $internal);

            throw $unrecoverable;
        } catch (UnrecoverableJobExceptionInterface $e) {
            $this->failedJob($job, $e, $internal);

            throw $e;
        } catch (\Throwable $e) {
            if (!$job instanceof RetryableJob) {
                $unrecoverable = new UnrecoverableJobException('Job failed and is not retryable', 0, $e);
                $this->failedJob($job, $unrecoverable, $internal);

                throw $unrecoverable;
            }

            if ($job->getRetryCount() >= $retryLimit) {
                $unrecoverable = new UnrecoverableJobException('Job reached retry limit and won\'t be retried again', 0, $e);
                $this->failedJob($job, $unrecoverable, $internal);

                throw $unrecoverable;
            }

            $this->failedJob($job, $e, $internal);

            throw $e;
        }
        $this->finishJob($job, $internal);
    }
820763
public function handle(LaravelJobFailed $event)
    {
        if (! $event->job instanceof RedisJob) {
            return;
        }

        $this->events->dispatch((new JobFailed(
            $event->exception, $event->job, $event->job->getReservedJob()
        ))->connection($event->connectionName)->queue($event->job->getQueue()));
    }