Illuminate\Queue\Worker::runNextJob PHP Method

runNextJob() public method

Process the next job on the queue.
public runNextJob ( string $connectionName, string $queue, WorkerOptions $options ) : void
$connectionName string
$queue string
$options WorkerOptions
return void
    public function runNextJob($connectionName, $queue, WorkerOptions $options)
    {
        $job = $this->getNextJob($this->manager->connection($connectionName), $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 ($job) {
            return $this->runJob($job, $connectionName, $options);
        }
        $this->sleep($options->sleep);
    }

Usage Example

 /**
  * Run the worker instance.
  *
  * @param  string  $connection
  * @param  string  $queue
  * @param  int  $delay
  * @param  int  $memory
  * @param  bool  $daemon
  * @return array
  */
 protected function runWorker($connection, $queue, $delay, $memory, $daemon = false)
 {
     $this->worker->setExceptionHandler($this->laravel['Illuminate\\Contracts\\Debug\\ExceptionHandler']);
     if ($daemon) {
         $this->worker->setCache($this->laravel['cache']->driver());
         return $this->worker->daemon($connection, $queue, $delay, $memory, $this->option('timeout', 60), $this->option('sleep'), $this->option('tries'));
     }
     return $this->worker->runNextJob($connection, $queue, $delay, $this->option('sleep'), $this->option('tries'));
 }