/** * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output) { while ($jobData = $this->scheduler->retrieve()) { $output->writeln("Job {$jobData['id']} added."); $this->jobQueue->put($this->createJob($jobData)); $this->scheduler->remove($jobData['id']); } }
public function testMarkAsIncompleteReleasesBeanstalkJobWhenDelayIsMoreProlonged() { $jobId = 123; $job = $this->getMock('\\Phlib\\JobQueue\\JobInterface'); $job->expects($this->any())->method('getId')->will($this->returnValue($jobId)); $this->scheduler->expects($this->any())->method('shouldBeScheduled')->will($this->returnValue(true)); $this->scheduler->expects($this->once())->method('store')->with($this->equalTo($job)); $this->jobQueue->markAsIncomplete($job); }
/** * @inheritdoc */ public function markAsIncomplete(JobInterface $job) { if ($this->scheduler->shouldBeScheduled($job->getDelay())) { if ($job->getId() !== null) { $this->beanstalk->delete($job->getId()); } return $this->scheduler->store($job); } else { return $this->beanstalk->useTube($job->getQueue())->release($job->getId(), $job->getPriority(), $job->getDelay()); } }