Retrieves one or more messages, with a maximum limit of 10 messages, from
the specified queue. Long poll support is enabled by using the
WaitTimeSeconds
parameter. For more information, see Amazon SQS Long Poll in the Amazon SQS Developer Guide.
Short poll is the default behavior where a weighted random set of
machines is sampled on a ReceiveMessage
call. This means
only the messages on the sampled machines are returned. If the number of
messages in the queue is small (less than 1000), it is likely you will
get fewer messages than you requested per ReceiveMessage
call. If the number of messages in the queue is extremely small, you
might not receive any messages in a particular
ReceiveMessage
response; in which case you should repeat the
request.
For each message returned, the response includes the following:
-
Message body
-
MD5 digest of the message body. For information about MD5, see RFC1321.
-
Message ID you received when you sent the message to the queue.
-
Receipt handle.
-
Message attributes.
-
MD5 digest of the message attributes.
The receipt handle is the identifier you must provide when deleting the
message. For more information, see Queue and Message Identifiers in the Amazon SQS Developer
Guide.
You can provide the VisibilityTimeout
parameter in your
request, which will be applied to the messages that Amazon SQS returns in
the response. If you don't include the parameter, the overall visibility
timeout for the queue is used for the returned messages. For more
information, see Visibility Timeout in the Amazon SQS Developer Guide.
A message that is not deleted or a message whose visibility is not
extended before the visibility timeout expires counts as a failed
receive. Depending on the configuration of the queue, the message might
be sent to the dead letter queue.
Going forward, new attributes might be added. If you are writing code
that calls this action, we recommend that you structure your code so that
it can handle new attributes gracefully.