protected function reserve($timeout)
    {
        $response = $this->getClient()->receiveMessage([
            'QueueUrl' => $this->url,
            'AttributeNames' => ['ApproximateReceiveCount'],
            'MessageAttributeNames' => ['TTR'],
            'MaxNumberOfMessages' => 1,
            'VisibilityTimeout' => $this->ttr,
            'WaitTimeSeconds' => $timeout,
        ]);
        if (!$response['Messages']) {
            return null;
        }

        $payload = reset($response['Messages']);

        $ttr = (int) $payload['MessageAttributes']['TTR']['StringValue'];
        if ($ttr != $this->ttr) {
            $this->getClient()->changeMessageVisibility([
                'QueueUrl' => $this->url,
                'ReceiptHandle' => $payload['ReceiptHandle'],
                'VisibilityTimeout' => $ttr,
            ]);
        }

        return $payload;
    }
protected function reserve($timeout)
    {
        $response = $this->getClient()->receiveMessage([
            'QueueUrl' => $this->url,
            'AttributeNames' => ['ApproximateReceiveCount'],
            'MessageAttributeNames' => ['TTR'],
            'MaxNumberOfMessages' => 1,
            'VisibilityTimeout' => $this->ttr,
            'WaitTimeSeconds' => $timeout,
        ]);
        if (!$response['Messages']) {
            return null;
        }

        $payload = reset($response['Messages']);

        $ttr = (int) $payload['MessageAttributes']['TTR']['StringValue'];
        if ($ttr != $this->ttr) {
            $this->getClient()->changeMessageVisibility([
                'QueueUrl' => $this->url,
                'ReceiptHandle' => $payload['ReceiptHandle'],
                'VisibilityTimeout' => $ttr,
            ]);
        }

        return $payload;
    }
protected function reserve ( $ timeout ) { $ response = $ this -> getClient ( ) -> receiveMessage ( [ 'QueueUrl' => $ this -> url , 'AttributeNames' => [ 'ApproximateReceiveCount' ] , 'MessageAttributeNames' => [ 'TTR' ] , 'MaxNumberOfMessages' => 1 , 'VisibilityTimeout' => $ this -> ttr , 'WaitTimeSeconds' => $ timeout , ] ) ; if ( ! $ response [ 'Messages' ] ) { return null ; } $ payload = reset ( $ response [ 'Messages' ] ) ; $ ttr = ( int ) $ payload [ 'MessageAttributes' ] [ 'TTR' ] [ 'StringValue' ] ; if ( $ ttr != $ this -> ttr ) { $ this -> getClient ( ) -> changeMessageVisibility ( [ 'QueueUrl' => $ this -> url , 'ReceiptHandle' => $ payload [ 'ReceiptHandle' ] , 'VisibilityTimeout' => $ ttr , ] ) ; } return $ payload ; }
Gets a single message from SQS queue and sets the visibility to reserve message.

@param int $timeout number of seconds for long polling. Must be between 0 and 20.
@return null|array payload.
Gets a single message from SQS queue and sets the visibility to reserve message .