Log a failed job into storage.

@param  string  $connection
@param  string  $queue
@param  string  $payload
@return void
170465
public function log($connection, $queue, $payload)
	{
		$failed_at = new DateTime;

		$this->getTable()->insert(compact('connection', 'queue', 'payload', 'failed_at'));
	}
666768
protected function raiseBeforeJobEvent($connection, Job $job)
    {
        if (isset($this->events)) {
            $this->events->dispatch('nova.queue.processing', array($connection, $job));
        }
    }
900126
public function pushRaw($payload, $queue = null, array $options = [])
    {
        $payload = (new JobPayload($payload))->prepare($this->lastPushed)->value;

        return tap(parent::pushRaw($payload, $queue, $options), function () use ($queue, $payload) {
            $this->event($this->getQueue($queue), new JobPushed($payload));
        });
    }
141556
public function perform(JobInterface $job)
    {
        try {
            $job->perform();
        } catch (Exception $e) {
            $this->logger->notice('{job} failed: {exception}', array(
                'job'     => $job,
                'exception' => $e
            ));
            $this->failJob($job, $e);
            return;
        }

        try {
            $this->resque->getStatusFactory()->forJob($job)->update(Status::STATUS_COMPLETE);
        } catch (JobIdException $e) {
            $this->logger->warning('Could not mark job complete: no ID in payload - {exception}', array('exception' => $e));
        }

        $payload = $job->getPayload();

        $this->logger->notice('Finished job {queue}/{class} (ID: {id})', array(
            'queue' => $job->getQueue(),
            'class' => get_class($job),
            'id'    => isset($payload['id']) ? $payload['id'] : 'unknown'
        ));

        $this->logger->debug('Done with {job}', array('job' => $job));
    }
190130
public function log( $connection, $queue, $payload )
	{
		$failed_at = Carbon::now();

		return $this->getTable()->insertGetId( compact( 'connection', 'queue', 'payload', 'failed_at' ) );
	}
533769
protected function daemonShouldRun($connection, $queue)
    {
        if ($this->manager->isDownForMaintenance()) {
            return false;
        }

        $result = $this->events->until('nova.queue.looping', array($connection, $queue));

        return ($result !== false);
    }
761147
public function release($queue, $job, $delay)
    {
        return $this->pushToDatabase($queue, $job->payload, $delay, $job->attempts);
    }
352320
protected function logFailedJob( $connection, Job $job )
	{
		if ( $this->failer )
		{
			$failedId = $this->failer->log( $connection, $job->getQueue(), $job->getRawBody() );
			$job->delete();
			$job->failed();
			$this->raiseFailedJobEvent( $connection, $job, $failedId );
		}

		return ['job' => $job, 'failed' => true];
	}
1003999
public function process($connection, Job $job, $maxTries = 0, $delay = 0)
	{
		if ($maxTries > 0 && $job->attempts() > $maxTries)
		{
			return $this->logFailedJob($connection, $job);
		}

		try
		{
			// First we will fire off the job. Once it is done we will see if it will
			// be auto-deleted after processing and if so we will go ahead and run
			// the delete method on the job. Otherwise we will just keep moving.
			$job->fire();

			return ['job' => $job, 'failed' => false];
		}

		catch (Exception $e)
		{
			// If we catch an exception, we will attempt to release the job back onto
			// the queue so it is not lost. This will let is be retried at a later
			// time by another listener (or the same one). We will do that here.
			if ( ! $job->isDeleted()) $job->release($delay);

			throw $e;
		}
	}
1115292
public function failed()
	{
		$payload = json_decode($this->getRawBody(), true);

		list($class, $method) = $this->parseJob($payload['job']);

		$this->instance = $this->resolve($class);

		if (method_exists($this->instance, 'failed')) {
			$this->instance->failed($this->resolveQueueableEntities($payload['data']));
		}
	}
437171
protected function defaultJobData($connection, $queue, array $payload, array $data)
    {
        return [
            'connection' => $connection,
            'queue' => $queue,
            'name' => $payload['displayName'],
            'tries' => $payload['maxTries'],
            'timeout' => $payload['timeout'],
            'data' => $data,
        ];
    }
638556
private function handleErrorResponse(string $connectionName, MessageEnvelopeQueue $queue, Response $response)
    {
        $error = $response->getResponse();
        if (false === is_array($error) or !array_key_exists('identifier', $error)) {
            $queue->traverseWith(function (MessageEnvelope $messageEnvelope) {
                $messageEnvelope->setState(MessageEnvelope::FAILED);
            });
            $queue->clear();
            throw new AppleNotifyFailedException('Message gave an error but no response all messages marked as failed');
        }
        // Get all the items that are sent before or are the failed identifier
        $preIdentifierQueue = $queue->split($error['identifier']);
        // remove the failed identifier from the queue so we can fail it
        $failedMessage = $preIdentifierQueue->remove($error['identifier'])->getOrThrow(new AppleNotifyFailedException('Failed identifier not found: ' . $error['identifier']));
        $failedMessage->setState(MessageEnvelope::FAILED);
        $failedMessage->setResponse($response);
        // every message before the failed one are successful
        $preIdentifierQueue->traverseWith(function (MessageEnvelope $messageEnvelope) {
            $messageEnvelope->setState(MessageEnvelope::SUCCESS);
        });
        // reflush the remainder of the queue these messages have to be send again
        $this->flushQueueItem($connectionName, $queue);
    }
293821
protected function addPendingEvent($connection, $event, $payload)
    {
        $connectionId = $connection->getName();
        $transactionLevel = $this->transactionLevel;

        $eventData = [
            'event' => $event,
            'payload' => is_object($payload) ? clone $payload : $payload,
        ];
        $transactionLevelEvents = &$this->pendingEvents[$connectionId][$transactionLevel];
        $transactionLevelEvents[count($transactionLevelEvents) - 1][] = $eventData;
    }
986290
protected function withCreatePayloadHooks($queue, array $payload)
    {
        if (! empty(static::$createPayloadCallbacks)) {
            foreach (static::$createPayloadCallbacks as $callback) {
                $payload = array_merge($payload, call_user_func(
                    $callback, $this->getConnectionName(), $queue, $payload
                ));
            }
        }

        return $payload;
    }
152349
protected function raiseExceptionOccurredJobEvent( $connection, Job $job, $exception )
	{
		$data = json_decode( $job->getRawBody(), true );
		Framework::hooks()->trigger( 'queue.job.exception', compact( 'connection', 'job', 'data', 'exception' ) );
	}
35859
public function deleteReserved($queue, $job)
    {
        $this->getConnection()->zrem($this->getQueue($queue).':reserved', $job);
    }
544797
protected function logFailedJob(JobFailed $event)
    {
        $this->app['queue.failer']->log(
            $event->connector, $event->job->getQueue(),
            $event->job->getRawBody(), $event->exception
        );
    }