예제 #1
0
 public function addJob(JobInterface $job, $routingKey = self::DEFAULT_ROUTING_KEY)
 {
     $model = \Task::getById($job->getId());
     $model->broker_name = $this->name;
     $model->routing_key = $routingKey;
     return $model->save();
 }
예제 #2
0
 /**
  * @return null|TaskInterface
  */
 private function getNextTask()
 {
     pcntl_signal_dispatch();
     if ($this->isTerminated) {
         return null;
     }
     if (null == $this->currentJob) {
         $this->currentJob = $this->getNextJob();
         if (!$this->currentJob) {
             return null;
         }
         $this->jobs[$this->currentJob->getId()] = $this->currentJob;
         $this->currentJob->start();
     }
     $task = $this->currentJob->getNextTask();
     if (!$task) {
         $this->currentJob = $this->getNextJob();
         if (!$this->currentJob) {
             return null;
         }
         $this->jobs[$this->currentJob->getId()] = $this->currentJob;
         $this->currentJob->start();
         $task = $this->currentJob->getNextTask();
     }
     return $task;
 }