Example #1
0
 /**
  * Add a job to the queue.
  *
  * @param  JobInterface $job
  * @param  string       $channel
  * @return mixed
  */
 public function dispatch(JobInterface $job, $channel = QueueInterface::MAIN_CHANNEL)
 {
     $dispatched_job_id = $this->dispatcher->dispatch($job->setBatch($this), $channel);
     $this->dispatched_job_ids[] = $dispatched_job_id;
     return $dispatched_job_id;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function execute(JobInterface $job, $silent = true)
 {
     return $job->execute();
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function reportBackgroundProcess(JobInterface $job, $process_id)
 {
     if ($job->getQueue() && get_class($job->getQueue()) == get_class($this)) {
         if ($job_id = $job->getQueueId()) {
             if (is_int($process_id) && $process_id > 0) {
                 if ($this->connection->executeFirstCell('SELECT COUNT(`id`) AS "row_count" FROM `' . self::JOBS_TABLE_NAME . '` WHERE `id` = ? AND `reserved_at` IS NOT NULL', $job_id)) {
                     $this->connection->execute('UPDATE `' . self::JOBS_TABLE_NAME . '` SET `process_id` = ? WHERE `id` = ?', $process_id, $job_id);
                 } else {
                     throw new InvalidArgumentException('Job not found or not running');
                 }
             } else {
                 throw new InvalidArgumentException('Process ID is required (a non-negative integer is expected)');
             }
         } else {
             throw new InvalidArgumentException('Only enqueued jobs can report background processes');
         }
     } else {
         throw new InvalidArgumentException('Job does not belong to this queue');
     }
 }