예제 #1
0
 /**
  * Esegue il worker ad libitum
  *
  * @param string $tube
  * @return void
  */
 public function execute($tube)
 {
     $queue = new Pheanstalk($this->host);
     declare (ticks=1);
     $tube = !is_null($tube) ? QueueManager::resolveChannelName($tube) : null;
     $queue->watch($tube);
     pcntl_signal(SIGTERM, function ($signal) use($tube) {
         $this->shouldClose = true;
         if ((int) QueueManager::getTubeStats($tube, 'current-jobs-ready') === 0) {
             exit;
         }
     });
     while ($job = $queue->reserve()) {
         try {
             $this->log($job, "Starting Job...");
             $this->jobRunner->execute($job, $this->logger);
         } catch (\Exception $e) {
             $this->log($job, "Job Failed and Buried: " . $e->getMessage(), LoggerInterface::SEVERITY_ERROR);
             $queue->bury($job);
             continue;
         }
         $this->log($job, "Job Finished Succesfully");
         $queue->delete($job);
         $this->closeIfPossible();
     }
 }
 /**
  * @inheritdoc
  */
 public function abort($messageId)
 {
     $pheanstalkJob = $this->client->peek((int) $messageId);
     $this->client->bury($pheanstalkJob);
 }
예제 #3
0
 /**
  * Bury the job in the queue.
  *
  * @return void
  */
 public function bury()
 {
     $this->pheanstalk->bury($this->job);
 }
예제 #4
0
 /**
  * Bury the job in the queue.
  *
  * @return void
  */
 public function bury()
 {
     parent::release();
     $this->pheanstalk->bury($this->job);
 }
 /**
  * @param Job $job
  */
 public function bury(Job $job)
 {
     $this->connection->bury($job);
 }
 /**
  * Valid option is:
  *      - priority: the lower the priority is, the sooner the job get kicked
  *
  * {@inheritDoc}
  */
 public function bury(JobInterface $job, array $options = array())
 {
     $this->pheanstalk->bury($job, isset($options['priority']) ? $options['priority'] : Pheanstalk::DEFAULT_PRIORITY);
 }