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(); }
/** * @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; }