title: SQS: Get Message Available
body: <p>I'm writing a script to limit/control the number of messages for each queue when it reached a certain threshold. I want to read how many available messages in the queue before adding more messages to it.</p>
  
  <p>Example:
  Users will receive an error message to try again in few minutes because server is busy processing message when queue is around 100 messages pending and it will accept message again when pending messages in the queue is below 30..</p>
  
  <p>I was looking at the SQS PHP methods and I don not see any method to view the current size of the queue or the available messages for the workers - <a href="http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.Sqs.SqsClient.html" rel="nofollow noreferrer">http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.Sqs.SqsClient.html</a></p>
  
  <p>Is there any way to read the message available in a queue? </p>
  
  <p><img src="https://i.stack.imgur.com/5Kyda.png" alt="enter image description here"></p>