I am using the AWS SDK in PHP to communicate with an SQS queue. At the moment the queue just has simple test messages contained within it. I am attempting to read the next 10 messages from the queue. To do this I have set MaximumNumberOfMessages to 10 and also set the WaitTimeSeconds to 20.
My understanding of this should be that the SqsClient will connect and consume messages from the queue until it has either the number of messages (10) or reaches the timeout (20) seconds.
However the client is returning almost instantly and with only 3-4 messages (now there are +20 messages in the queue). When there were only 4-5 messages it would return with just one message.
I have also set the VisibilityTimeout to just be 1 second, and am not running the test script in a loop, just firing manually from the CLI.
The array I am passing to SqsClient receiveMessage is :
[
'QueueUrl' => $this->uri,
'MaxNumberOfMessages' => 10,
'VisibilityTimeout' => 1,
'WaitTimeSeconds' => 20,
]
Any ideas why the call isn't waiting for the full 20 seconds at least (for small number of queue messages), and not returning more than a few messages (for a fuller queue) ?
Thanks