src/Queue/MongoQueue.php
public function pop(array $options = [])
    {
        $time      = microtime(true);
        $micro     = sprintf("%06d", ($time - floor($time)) * 1000000);
        $this->now = new \DateTime(
            date('Y-m-d H:i:s.' . $micro, $time),
            new \DateTimeZone(date_default_timezone_get())
        );
        $now = $this->dateTimeToUTCDateTime($this->now);

        $envelope = $this->mongoCollection->findOneAndUpdate(
            [
                'queue' => $this->getName(),
                'status' => self::STATUS_PENDING,
                'scheduled' => ['$lte' => $now],
            ],
            [
                '$set' => [
                    'status' => self::STATUS_RUNNING,
                    'executed' => $now,
                ],
            ],
            [
                'sort' => ['priority' => 1, 'scheduled' => 1],
                'returnDocument' => \MongoDB\Operation\FindOneAndUpdate::RETURN_DOCUMENT_AFTER
            ]
        );

        if (!$envelope) {
            return null;
        }

        return $this->unserializeJob($envelope['data'], ['__id__' => $envelope['_id']]);
    }
public function pop(array $options = [])
    {
        $time      = microtime(true);
        $micro     = sprintf("%06d", ($time - floor($time)) * 1000000);
        $this->now = new \DateTime(
            date('Y-m-d H:i:s.' . $micro, $time),
            new \DateTimeZone(date_default_timezone_get())
        );
        $now = $this->dateTimeToUTCDateTime($this->now);

        $envelope = $this->mongoCollection->findOneAndUpdate(
            [
                'queue' => $this->getName(),
                'status' => self::STATUS_PENDING,
                'scheduled' => ['$lte' => $now],
            ],
            [
                '$set' => [
                    'status' => self::STATUS_RUNNING,
                    'executed' => $now,
                ],
            ],
            [
                'sort' => ['priority' => 1, 'scheduled' => 1],
                'returnDocument' => \MongoDB\Operation\FindOneAndUpdate::RETURN_DOCUMENT_AFTER
            ]
        );

        if (!$envelope) {
            return null;
        }

        return $this->unserializeJob($envelope['data'], ['__id__' => $envelope['_id']]);
    }
Pop a job from the queue.

The status will be set to self::STATUS_RUNNING.

@param array $options unused
@return null|JobInterface