title: Number of messages in Amazon SQS
body: <p>I am trying to learn Amazon SQS. I am sending multiple message requests to my SQS like </p>
  
  <pre><code>    sendMessage(sqs, qUrl, "message 1");
      sendMessage(sqs, qUrl, "message 2");
      sendMessage(sqs, qUrl, "message 3");
      sendMessage(sqs, qUrl, "message 4");
      sendMessage(sqs, qUrl, "message 5");
  </code></pre>
  
  <p><strong>Note:</strong> In the parameters I pass, <strong>sqs</strong> and <strong>qUrl</strong> are all the same.</p>
  
  <p><strong>//sendMessage method:</strong></p>
  
  <pre><code>public void sendMessage(AmazonSQS sqs, String queueUrl, String msg){
          SendMessageRequest smr = new SendMessageRequest(queueUrl, msg);
          sqs.sendMessage(smr);
      }
  </code></pre>
  
  <p>But still when I try to count the numberOfRequests in the queue, it is 1 and not 5.</p>
  
  <pre><code>public int countRequests(AmazonSQS sqs, String queueUrl){
          // Receive messages
          int numberOfMessages=0;
          System.out.println("Receiving messages");
          ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(queueUrl);
          messages = sqs.receiveMessage(receiveMessageRequest).getMessages();
          for (Message message : messages) {
              numberOfMessages++;
              System.out.println("  Message");
              System.out.println("    MessageId:     " + message.getMessageId());
              System.out.println("    ReceiptHandle: " + message.getReceiptHandle());
              System.out.println("    MD5OfBody:     " + message.getMD5OfBody());
              System.out.println("    Body:          " + message.getBody());
              for (Entry&lt;String, String&gt; entry : message.getAttributes().entrySet()) {
                  System.out.println("  Attribute");
                  System.out.println("    Name:  " + entry.getKey());
                  System.out.println("    Value: " + entry.getValue());
              }
          }
          return numberOfMessages;
      }
  </code></pre>
  
  <p><em>Here</em>,</p>
  
  <pre><code>ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(queueUrl);
    messages = sqs.receiveMessage(receiveMessageRequest).getMessages();
  </code></pre>
  
  <p><em><strong>"messages"</strong> receive only the last message and not the first 4.</em></p>
  
  <p>My understanding is that I should be having 5 message requests in my queue. What am I missing out? Or Have I understood wrongly? Please correct me.</p>