private function loadIdentities()
 {
     $model = JobIdentity::model();
     $criteria = new \CDbCriteria();
     $criteria->addCondition('broker_name = :name');
     $criteria->addCondition('routing_key = :key');
     $criteria->addCondition('status = ' . JobInterface::IS_NEW);
     $criteria->order = 'task_id';
     $criteria->limit = 5;
     //1000; todo
     $criteria->params = [':name' => $this->broker->getName(), ':key' => $this->routingKey];
     /**
      * @var JobIdentity[] $identities
      */
     $identities = $model->findAll($criteria);
     $identityIds = [];
     foreach ($identities as $identity) {
         $this->identities[$identity->getId()] = $identity;
         $identityIds[] = $identity->getId();
     }
     $model->updateByPk($identityIds, ['status' => JobInterface::SCHEDULED]);
 }
Exemple #2
0
 public function addToBroker(JobInterface $job, $brokerName, $routingKey = JobBroker::DEFAULT_ROUTING_KEY)
 {
     $broker = new JobBroker($brokerName);
     return $broker->addJob($job, $routingKey);
 }