src/Queue/MongoQueue.php
function pop($queue = null)
    {
        try {
            $queued = $this->collection->findOneAndUpdate(
                [
                    'queue' => $this->_normalizeQueueName($queue),
                    'pop'   => false,
                ]
                , [
                    '$set' => ['pop' => true]
                ]
                , [
                    // pick last one in the queue
                    'sort'    => [ '_id' => -1 ],
                    // override typeMap option
                    'typeMap' => self::$typeMap,
                ]
            );
        } catch (\Exception $e) {
            throw new exReadError('Error While Write To Mongo Client.', $e->getCode(), $e);
        }

        if (! $queued )
            return null;


        $payload = $this->_interchangeable()
            ->retrieveBackward($queued['payload']);

        $payload = $payload->withQueue($queue)
            ->withUID( (string) $queued['_id'] );

        return $payload;
    }
function pop($queue = null)
    {
        try {
            $queued = $this->collection->findOneAndUpdate(
                [
                    'queue' => $this->_normalizeQueueName($queue),
                    'pop'   => false,
                ]
                , [
                    '$set' => ['pop' => true]
                ]
                , [
                    // pick last one in the queue
                    'sort'    => [ '_id' => -1 ],
                    // override typeMap option
                    'typeMap' => self::$typeMap,
                ]
            );
        } catch (\Exception $e) {
            throw new exReadError('Error While Write To Mongo Client.', $e->getCode(), $e);
        }

        if (! $queued )
            return null;


        $payload = $this->_interchangeable()
            ->retrieveBackward($queued['payload']);

        $payload = $payload->withQueue($queue)
            ->withUID( (string) $queued['_id'] );

        return $payload;
    }
Pop From Queue

note: when you pop a message from queue you have to
release it when worker done with it.


@param string $queue

@return iPayloadQueued|null
@throws exIOError