예제 #1
0
파일: Array.php 프로젝트: apinstein/jqjobs
 public function enqueue(JQJob $job)
 {
     $existingManagedJob = $this->existsJobForCoalesceId($job->coalesceId());
     if ($existingManagedJob) {
         return $existingManagedJob;
     }
     $mJob = new JQManagedJob($this, $job);
     $jobId = $this->nextJobId();
     $mJob->setJobId($jobId);
     $this->queue[$jobId] = $mJob;
     $mJob->setStatus(JQManagedJob::STATUS_QUEUED);
     return $mJob;
 }
예제 #2
0
파일: Propel.php 프로젝트: apinstein/jqjobs
 public function enqueue(JQJob $job)
 {
     $mJob = NULL;
     $this->con->beginTransaction();
     try {
         // look for coalesceId collision
         $coalesceId = $job->coalesceId();
         $mJob = $this->existsJobForCoalesceId($job->coalesceId());
         if (!$mJob) {
             // create a new job
             $mJob = new JQManagedJob($this, $job);
             $mJob->setStatus(JQManagedJob::STATUS_QUEUED);
             $dbJob = new $this->propelClassName();
             $dbJob->fromArray($mJob->toArray($this->options['toArrayOptions']), BasePeer::TYPE_STUDLYPHPNAME);
             $dbJob->save($this->con);
             $mJob->setJobId($dbJob->getJobId());
         }
         $this->con->commit();
     } catch (Exception $e) {
         $this->con->rollback();
         throw $e;
     }
     return $mJob;
 }
예제 #3
0
 public function setJob(JQJob $job)
 {
     if ($this->job !== NULL) {
         throw new JQManagedJob_AlreadyHasAJobException();
     }
     $this->job = $job;
     $this->setCoalesceId($job->coalesceId());
     $options = $job->getEnqueueOptions();
     if (isset($options['startDts'])) {
         $this->startDts = $options['startDts'];
     }
     if (isset($options['priority'])) {
         $this->priority = $options['priority'];
     }
     if (isset($options['maxAttempts'])) {
         $this->maxAttempts = $options['maxAttempts'];
     }
     if (isset($options['queueName'])) {
         $this->queueName = $options['queueName'];
     }
     if (isset($options['deleteOnComplete'])) {
         $this->deleteOnComplete = $options['deleteOnComplete'];
     }
     if (isset($options['maxRuntimeSeconds'])) {
         $this->maxRuntimeSeconds = $options['maxRuntimeSeconds'];
     }
 }