Exemple #1
0
 /**
  * Listen to the given queue.
  *
  * @param  string  $connectionName
  * @param  string  $queue
  * @param  int     $delay
  * @param  int     $memory
  * @param  int     $sleep
  * @param  int     $maxTries
  * @return void
  */
 public function pop($connectionName, $queue = null, $delay = 0, $memory = 128, $sleep = 3, $maxTries = 0)
 {
     $connection = $this->manager->connection($connectionName);
     $job = $this->getNextJob($connection, $queue);
     // If we're able to pull a job off of the stack, we will process it and
     // then make sure we are not exceeding our memory limits for the run
     // which is to protect against run-away memory leakages from here.
     if (!is_null($job)) {
         $this->process($this->manager->getName($connectionName), $job, $maxTries, $delay);
     } else {
         $this->sleep($sleep);
     }
 }
 /**
  * Listen to the given queue.
  *
  * @param  string  $connectionName
  * @param  string  $queue
  * @param  int     $delay
  * @param  int     $sleep
  * @param  int     $maxTries
  * @return array
  */
 public function pop($connectionName, $queue = null, $delay = 0, $sleep = 3, $maxTries = 0)
 {
     $connection = $this->manager->connection($connectionName);
     $job = $this->getNextJob($connection, $queue);
     // If we're able to pull a job off of the stack, we will process it and
     // then immediately return back out. If there is no job on the queue
     // we will "sleep" the worker for the specified number of seconds.
     if (!is_null($job)) {
         return $this->process($this->manager->getName($connectionName), $job, $maxTries, $delay);
     }
     $this->sleep($sleep);
     return ['job' => null, 'failed' => false];
 }
 /**
  * Process the next job on the queue.
  *
  * @param  string  $connectionName
  * @param  string  $queue
  * @param  int     $delay
  * @param  int     $sleep
  * @param  int     $maxTries
  * @return void
  */
 public function runNextJob($connectionName, $queue = null, $delay = 0, $sleep = 3, $maxTries = 0)
 {
     try {
         $connection = $this->manager->connection($connectionName);
         $job = $this->getNextJob($connection, $queue);
         // If we're able to pull a job off of the stack, we will process it and then return
         // from this method. If there is no job on the queue, we will "sleep" the worker
         // for the specified number of seconds, then keep processing jobs after sleep.
         if (!is_null($job)) {
             return $this->process($this->manager->getName($connectionName), $job, $maxTries, $delay);
         }
     } catch (Exception $e) {
         if ($this->exceptions) {
             $this->exceptions->report($e);
         }
     }
     $this->sleep($sleep);
 }
Exemple #4
0
 /**
  * Get the full name for the given connection.
  *
  * @param string $connection
  * @return string 
  * @static 
  */
 public static function getName($connection = null)
 {
     return \Illuminate\Queue\QueueManager::getName($connection);
 }