コード例 #1
0
 public function testRecreatedJobMatchesExistingJob()
 {
     $args = array('int' => 123, 'numArray' => array(1, 2), 'assocArray' => array('key1' => 'value1', 'key2' => 'value2'));
     Resque::enqueue('jobs', TestJob::className(), $args);
     $job = Job::reserve('jobs');
     // Now recreate it
     $job->recreate();
     $newJob = Job::reserve('jobs');
     $this->assertEquals($job->payload['class'], $newJob->payload['class']);
     $this->assertEquals($job->payload['args'], $newJob->getArguments());
 }
コード例 #2
0
 /**
  * Attempt to find a job from the top of one of the queues for this worker.
  *
  * @return object|boolean Instance of Job if a job is found, false if not.
  */
 public function reserve()
 {
     $queues = $this->queues();
     if (!is_array($queues)) {
         return;
     }
     foreach ($queues as $queue) {
         $this->log('Checking ' . $queue, self::LOG_VERBOSE);
         $job = Job::reserve($queue);
         if ($job) {
             $this->log('Found job on ' . $queue, self::LOG_VERBOSE);
             return $job;
         }
     }
     return false;
 }
コード例 #3
0
 public function testRecreatedJobWithTrackingStillTracksStatus()
 {
     $originalToken = Resque::enqueue('jobs', TestJob::className(), null, true);
     $job = $this->worker->reserve();
     // Mark this job as being worked on to ensure that the new status is still
     // waiting.
     $this->worker->workingOn($job);
     // Now recreate it
     $newToken = $job->recreate();
     // Make sure we've got a new job returned
     $this->assertNotEquals($originalToken, $newToken);
     // Now check the status of the new job
     $newJob = Job::reserve('jobs');
     $this->assertEquals(Status::STATUS_WAITING, $newJob->getStatus());
 }
コード例 #4
0
 /**
  * Reserve and return the next available job in the specified queue.
  *
  * @param string $queue Queue to fetch next available job from.
  * @return Job Instance of Job to be processed, false if none or error.
  */
 public static function reserve($queue)
 {
     return Job::reserve($queue);
 }