Beispiel #1
0
 /**
  * @param JobModel $job
  * @return bool
  * @throws HandlerException
  */
 public function handle(JobModel $job)
 {
     $success = true;
     $this->job = $job;
     list($fromStageNumber, $preloadedData) = $this->prepareStageData($job);
     foreach ($this->stages as $stage) {
         try {
             $stageNumber = $this->getStageNumber($stage);
             if ($stageNumber < $fromStageNumber) {
                 $this->logger->info("Skipping Stage because of retry");
                 continue;
             }
             $this->oracle->reset($job->id, $stage->getName());
             $continue = $this->handleStage($job, $stage, $preloadedData);
             $this->logger->info("Stage successfully processed");
             $this->oracle->reset($job->id);
             if (!$continue) {
                 break;
             }
         } catch (\Exception $e) {
             $this->logger->warning("Exception was thrown in the JobHandler handle() method, cannot continue (status: error)", ['exception_message' => $e->getMessage(), 'exception_trace' => $e->getTraceAsString()]);
             $this->jobRepo->update($job->id, ['status' => JobModel::STATUS_ERROR]);
             $success = false;
             break;
         }
     }
     if ($success) {
         $this->jobRepo->update($job->id, ['status' => JobModel::STATUS_HANDLED]);
     }
     return $success;
 }