Exemplo n.º 1
0
 /**
  * Handle the queue job.
  *
  * @param LaravelJob $laravelJob
  * @param mixed $data
  */
 public function fire(LaravelJob $laravelJob, $data)
 {
     $job = null;
     try {
         $job = $this->jobs->find($data['job_id']);
         // Check if the job is valid (not expired and ready). This might
         // happen on some timing edge cases.
         if (!$job->ready()) {
             $laravelJob->delete();
             return;
         }
         // Look for a task handler
         $handler = $this->resolver->resolve($job);
         if ($handler->getSpec() instanceof Spec) {
             $result = $handler->getSpec()->check($job->getData());
             if ($result->failed()) {
                 $laravelJob->delete();
                 $this->jobs->giveUp($job, 'Task data does not pass Spec.');
                 return;
             }
         }
         // Execute the handler
         $this->jobs->started($job, "Task handler started.\n");
         $handler->fire($job, $this->scheduler);
         $this->jobs->complete($job);
     } catch (ModelNotFoundException $e) {
         // Here we just cancel the queue job since there is no point in
         // retrying.
         $laravelJob->delete();
     } catch (UnresolvableException $e) {
         // Here we just cancel the queue job since there is no point in
         // retrying.
         $laravelJob->delete();
         $this->jobs->giveUp($job, 'Task handler was not found');
     } catch (Exception $e) {
         // If we were not able to find the job, just give up.
         if (is_null($job)) {
             $laravelJob->delete();
             return;
         }
         if ($job->hasAttemptsLeft()) {
             $this->jobs->release($job);
             $laravelJob->release();
             return;
         }
         $this->jobs->fail($job, 'Exception: ' . $e->getMessage());
         $laravelJob->delete();
     }
 }
 public function getFailed()
 {
     $jobs = $this->jobs->getFailedPaginated();
     return new Card([], [new CardHeader([], [new Row([], [new Column(['medium' => 6, 'class' => 'btn-y-align'], ['Failed Jobs']), new Column(['medium' => 6, 'class' => 'text-right'], [new Button(['class' => 'btn btn-sm btn-primary-outline'], 'Create new job')])])]), $this->renderJobsTable($jobs), new ConferencePaginator($jobs)]);
 }