src/AbstractQueue.php
final public function get(array $query, array $options = []) : array
    {
        $completeQuery = $this->buildPayloadQuery(
            ['earliestGet' => ['$lte' => new UTCDateTime((int)(microtime(true) * 1000))]],
            $query
        );

        $options += self::DEFAULT_GET_OPTIONS;
        $update = ['$set' => ['earliestGet' => $this->calculateEarliestGet($options['runningResetDuration'])]];
        $end = $this->calculateEndTime($options['waitDurationInMillis']);
        $sleepTime = $this->calculateSleepTime($options['pollDurationInMillis']);
        $messages = new ArrayObject();
        while (count($messages) < $options['maxNumberOfMessages']) {
            if ($this->tryFindOneAndUpdate($completeQuery, $update, $messages)) {
                continue;
            }

            if (microtime(true) < $end) {
                usleep($sleepTime);
            }

            break;
        }

        return $messages->getArrayCopy();
    }
final public function get(array $query, array $options = []) : array
    {
        $completeQuery = $this->buildPayloadQuery(
            ['earliestGet' => ['$lte' => new UTCDateTime((int)(microtime(true) * 1000))]],
            $query
        );

        $options += self::DEFAULT_GET_OPTIONS;
        $update = ['$set' => ['earliestGet' => $this->calculateEarliestGet($options['runningResetDuration'])]];
        $end = $this->calculateEndTime($options['waitDurationInMillis']);
        $sleepTime = $this->calculateSleepTime($options['pollDurationInMillis']);
        $messages = new ArrayObject();
        while (count($messages) < $options['maxNumberOfMessages']) {
            if ($this->tryFindOneAndUpdate($completeQuery, $update, $messages)) {
                continue;
            }

            if (microtime(true) < $end) {
                usleep($sleepTime);
            }

            break;
        }

        return $messages->getArrayCopy();
    }
Get a non running message from the queue.

@param array $query in same format as \MongoDB\Collection::find() where top level fields do not contain
operators. Lower level fields can however. eg: valid {a: {$gt: 1}, "b.c": 3},
invalid {$and: [{...}, {...}]}
@param array $options Associative array of get options.
runningResetDuration => integer
The duration (in miiliseconds) that the received messages are hidden from
subsequent retrieve requests after being retrieved by a get() request.
waitDurationInMillis => integer
The duration (in milliseconds) for which the call will wait for a message to
arrive in the queue before returning. If a message is available, the call will
return sooner than WaitTimeSeconds.
pollDurationInMillis => integer
The millisecond duration to wait between polls.
maxNumberOfMessages => integer
The maximum number of messages to return with get(). All of the messages are not
necessarily returned.

@return array Array of messages.

@throws \InvalidArgumentException key in $query was not a string