Exemplo n.º 1
0
 /**
  * Log a failed job into storage.
  *
  * @param  string  $connection
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @return array
  */
 protected function logFailedJob($connection, Job $job)
 {
     if ($this->failer) {
         $this->failer->log($connection, $job->getQueue(), $job->getRawBody());
         $job->delete();
         $job->failed();
         $this->raiseFailedJobEvent($connection, $job);
     }
     return ['job' => $job, 'failed' => true];
 }
Exemplo n.º 2
0
 /**
  * Mark the given job as failed and raise the relevant event.
  *
  * @param  string  $connectionName
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @param  \Exception  $e
  * @return void
  */
 protected function failJob($connectionName, $job, $e)
 {
     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 {
         $this->raiseFailedJobEvent($connectionName, $job, $e);
     }
 }
Exemplo n.º 3
0
 /**
  * Handle the failed job.
  *
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @param  \Exception  $e
  * @return array
  */
 protected function handleFailedJob(Job $job, $e)
 {
     $job->failed($e);
     $this->raiseFailedJobEvent($job, $e);
 }
Exemplo n.º 4
0
 /**
  * Mark the given job as failed if it has exceeded the maximum allowed attempts.
  *
  * @param  string  $connectionName
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @param  int  $maxTries
  * @param  \Exception  $e
  * @return void
  */
 protected function markJobAsFailedIfHasExceededMaxAttempts($connectionName, $job, $maxTries, $e)
 {
     if ($maxTries === 0 || $job->attempts() < $maxTries) {
         return;
     }
     // 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);
     $this->raiseFailedJobEvent($connectionName, $job, $e);
 }
Exemplo n.º 5
0
 /**
  * Fail the job from the queue.
  *
  * @param  \Throwable  $exception
  * @return void
  */
 public function fail($exception = null)
 {
     if ($this->job) {
         return $this->job->failed($exception ?: new ManuallyFailedException());
     }
 }
Exemplo n.º 6
0
 /**
  * Fail the job from the queue.
  *
  * @return void
  */
 public function failed()
 {
     if ($this->job) {
         return $this->job->failed();
     }
 }
Exemplo n.º 7
0
 /**
  * Log a failed job into storage.
  *
  * @param  string  $connection
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @return void
  */
 protected function logFailedJob($connection, Job $job)
 {
     if (!$this->failer) {
         return;
     }
     $failedId = $this->failer->log($connection, $job->getQueue(), $job->getRawBody());
     $job->delete();
     $job->failed();
     $this->raiseFailedJobEvent($connection, $job, $failedId);
 }