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; }
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; }