title: Retrieve multiple messages from SQS
body: <p>I have multiple messages in SQS.  The following code <strong>always</strong> returns only one, even if there are dozens visible (not in flight).  <a href="https://github.com/amazonwebservices/aws-sdk-for-java/blob/master/src/main/java/com/amazonaws/services/sqs/model/ReceiveMessageRequest.java#L195" rel="noreferrer">setMaxNumberOfMessages</a> I thought would allow multiple to be consumed at once .. have i misunderstood this?</p>
  
  <pre><code> CreateQueueRequest createQueueRequest = new CreateQueueRequest().withQueueName(queueName);
   String queueUrl = sqs.createQueue(createQueueRequest).getQueueUrl();
   ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(queueUrl);
   receiveMessageRequest.setMaxNumberOfMessages(10);
   List&lt;Message&gt; messages = sqs.receiveMessage(receiveMessageRequest).getMessages();
   for (Message message : messages) {
        // i'm a message from SQS
   }
  </code></pre>
  
  <p>I've also tried using <a href="https://github.com/amazonwebservices/aws-sdk-for-java/blob/master/src/main/java/com/amazonaws/services/sqs/model/ReceiveMessageRequest.java#L208" rel="noreferrer">withMaxNumberOfMessages</a> without any such luck:</p>
  
  <pre><code> receiveMessageRequest.withMaxNumberOfMessages(10);
  </code></pre>
  
  <p>How do I know there are messages in the queue?  More than 1?</p>
  
  <pre><code> Set&lt;String&gt; attrs = new HashSet&lt;String&gt;();
   attrs.add("ApproximateNumberOfMessages");
   CreateQueueRequest createQueueRequest = new CreateQueueRequest().withQueueName(queueName);
   GetQueueAttributesRequest a = new GetQueueAttributesRequest().withQueueUrl(sqs.createQueue(createQueueRequest).getQueueUrl()).withAttributeNames(attrs);
   Map&lt;String,String&gt; result = sqs.getQueueAttributes(a).getAttributes();
   int num = Integer.parseInt(result.get("ApproximateNumberOfMessages"));
  </code></pre>
  
  <p>The above always is run prior and gives me an <code>int</code> that is >1</p>
  
  <p>Thanks for your input</p>