Get the next job from the queue and remove it.

@param string $queueName (optional)

@return Job|null
961170
public function pop($queueName = '')
    {

        if (!isset($this->queues[$queueName])) {
            return null;
        }

        if (!$this->queues[$queueName]) {
            return null;
        }

        return array_pop($this->queues[$queueName]);
    }
210534
public function getQueueSettings(string $queueName): array
    {
        if (isset($this->queueSettingsRuntimeCache[$queueName])) {
            return $this->queueSettingsRuntimeCache[$queueName];
        }
        if (!isset($this->settings['queues'][$queueName])) {
            throw new JobQueueException(sprintf('Queue "%s" is not configured', $queueName), 1334054137);
        }
        $queueSettings = $this->settings['queues'][$queueName];
        if (isset($queueSettings['preset'])) {
            $presetName = $queueSettings['preset'];
            if (!isset($this->settings['presets'][$presetName])) {
                throw new JobQueueException(sprintf('Preset "%s", referred to in settings for queue "%s" is not configured', $presetName, $queueName), 1466677893);
            }
            $queueSettings = Arrays::arrayMergeRecursiveOverrule($this->settings['presets'][$presetName], $queueSettings);
        }
        $this->queueSettingsRuntimeCache[$queueName] = $queueSettings;
        return $this->queueSettingsRuntimeCache[$queueName];
    }
1136962
protected function retrieveNextJob($queue, $block = true)
    {
        $nextJob = $this->getConnection()->eval(
            LuaScripts::pop(), 3, $queue, $queue.':reserved', $queue.':notify',
            $this->availableAt($this->retryAfter)
        );

        if (empty($nextJob)) {
            return [null, null];
        }

        [$job, $reserved] = $nextJob;

        if (! $job && ! is_null($this->blockFor) && $block &&
            $this->getConnection()->blpop([$queue.':notify'], $this->blockFor)) {
            return $this->retrieveNextJob($queue, false);
        }

        return [$job, $reserved];
    }
1074840
public function pop($queue = null)
    {
        $queue = $queue ?: $this->queue;

        $job = $this->client->watchOnly($queue)->reserve(0);

        if (!$job instanceof Job) {
            return null;
        }

        $message = new QueueMessage();

        $message->setId($job->getId());
        $message->setAttempts($this->client->statsJob($job)->reserves);
        $message->setBody(json_decode($job->getData(), true));
        $message->setRawBody($job->getData());
        $message->setQueueName($queue ?: $this->queue);

        return $message;
    }
1038966
public function getQueueAliasByQueueName(string $queueName): string
    {
        return is_array($this->queues)
            ? ((array_flip($this->queues)[$queueName]) ?? $queueName)
            : $queueName;
    }
1329496
public function get(string $queue = 'default', $isAck = true, $timeout = null)
    {
        yield $this->beanstalkTask->watch($queue);
        $job = yield $this->beanstalkTask->reserve($timeout);
        if ($job && $isAck) {
            yield $this->beanstalkTask->delete($job);
        }

        return $job;
    }
128763
public function createQueue($queueName)
    {
        if ($this->queueExists($queueName)) {
            return;
        }

        $parameters = [
            'QueueName' => $queueName,
        ];

        if ($this->isFifoQueue($queueName)) {
            $parameters['Attributes'] = [
                'FifoQueue' => 'true',
            ];
        }

        $result = $this->sqs->createQueue($parameters);

        $this->queueUrls[$queueName] = $result['QueueUrl'];
    }
1087455
protected function get($queueName)
    {
        if (isset($this->caches[$queueName])) {
            return $this->caches[$queueName];
        }

        return $this->caches[$queueName] = new \SplQueue();
    }
932556
public function getQueue(): ?Queue
    {
        if (!$this->hasQueue()) {
            $this->setQueue($this->getDefaultQueue());
        }
        return $this->queue;
    }
1154880
public function queue(Queue $queue)
    {
        if (isset($this->delay)) {
            return $this->later($this->delay, $queue);
        }

        $connection = property_exists($this, 'connection') ? $this->connection : null;

        $queueName = property_exists($this, 'queue') ? $this->queue : null;

        return $queue->connection($connection)->pushOn(
            $queueName ?: null, new SendQueuedMailable($this)
        );
    }
725954
public function pop($queue = null)
    {
        $original = $queue ?: $this->default;

        $queue = $this->getQueue($queue);

        if ( ! is_null($this->expire)) {
            $this->migrateAllExpiredJobs($queue);
        }

        $job = $this->getConnection()->lpop($queue);

        if ( ! is_null($job)) {
            $this->getConnection()->zadd($queue.':reserved', $this->getTime() + $this->expire, $job);

            return new RedisJob($this->container, $this, $job, $original);
        }
    }
451761
public function pop($queue = null)
    {
        if (static::supportDelayed()) {
            $this->requeueDelayedItems();
        }

        $queue = $queue ?: $this->queue;

        $job = Resque::pop($queue);

        if (!$job) {
            return null;
        }

        $message = new QueueMessage();

        $attempts = $job['attempts'];
        $attempts++;

        $message->setId($job['id']);
        $message->setBody($job);
        $message->setRawBody(json_encode($job));
        $message->setQueueName($queue ?: $this->queue);
        $message->setAttempts($attempts);
        $message->set('attempts', $attempts);

        return $message;
    }
899191
public function pop($connectionName, $queue = null, $delay = 0, $sleep = 3, $maxTries = 0)
    {
        $connection = Queue::connection($connectionName);

        if ($job = $connection->pop($queue)) {
            return $this->process($job, $maxTries, $delay);
        }
        // Sleep the worker for the specified number of seconds, if no jobs
        sleep($sleep);
        return Result::success(null);
    }
351560
private function doPopMessage($queueName)
    {
        $query = 'SELECT id, message FROM bernard_messages
                  WHERE queue = :queue AND visible = :visible
                  ORDER BY sentAt LIMIT 1 '.$this->connection->getDatabasePlatform()->getForUpdateSql();

        list($id, $message) = $this->connection->fetchArray($query, [
            'queue' => $queueName,
            'visible' => true,
        ]);

        if ($id) {
            $this->connection->update('bernard_messages', ['visible' => 0], compact('id'));

            return [$message, $id];
        }
    }
181482
public function getQueueDriver($queueName)
    {
        $prefix = SmartboxIntegrationFrameworkExtension::QUEUE_DRIVER_PREFIX.$queueName;

        return $this->container->get($prefix);
    }
681849
public function pop($queue = null)
    {
        $queue = $queue ? $queue : $this->default;

        $this->database->beginTransaction();

        $query = Job::on($this->database->getName() )
            ->where('timestamp', '<', date('Y-m-d H:i:s', time()))
            ->where('queue', '=', $queue)
            ->where(function (Builder $query) {
                $query->where('status', '=', Job::STATUS_OPEN);
                $query->orWhere('status', '=', Job::STATUS_WAITING);
            })
            ->orderBy('id')
            ;
        // If requested set pessimistic lock
        if ($this->lock_type==self::LOCK_TYPE_SHARED) {
            $query->sharedLock();
        } elseif ($this->lock_type==self::LOCK_TYPE_FOR_UPDATE) {
            $query->lockForUpdate();
        }
        $job = $query->first();

        if (! is_null($job)) {
            // Mark job as started
            $job->status = Job::STATUS_STARTED;
            $job->save();

            $this->database->commit();
            $dbJob = new DatabaseJob($this->container, $job, $queue);
            return $dbJob;
        }
        else {
            $this->database->rollBack();
            return null;
        }
    }
320161
public function pop($queue = null)
    {
        $this->migrate($prefixed = $this->getQueue($queue));

        if (empty($nextJob = $this->retrieveNextJob($prefixed))) {
            return;
        }

        [$job, $reserved] = $nextJob;

        if ($reserved) {
            return new RedisJob(
                $this->container, $this, $job,
                $reserved, $this->connectionName, $queue ?: $this->default
            );
        }
    }