コード例 #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
ファイル: JQJobsTest.php プロジェクト: apinstein/jqjobs
 /**
  * @dataProvider failedJobDetectionDataProvider
  * @testdox JQManagedJob::run() will gracefully detect and fail a job that
  */
 function testFailedJobDetection($errorGeneratorF, $exceptionMessageContains)
 {
     // setup
     $q = new JQStore_Array();
     $mJob = new JQManagedJob($q, new SampleCallbackJob($errorGeneratorF));
     $mJob->setStatus(JQManagedJob::STATUS_QUEUED);
     $mJob->markJobStarted();
     // run
     $err = $mJob->run($mJob);
     $this->assertEquals(JQManagedJob::STATUS_FAILED, $mJob->getStatus(), "failed job not marked as failed.");
     $this->assertContains($exceptionMessageContains, $err, "JQManagedJob::run() failed to detect {$exceptionMessageContains}");
 }