Retrieves one or more messages from the queue specified, including the message body and message ID of each message. Messages returned by this action stay in the queue until deleted. However, once a message is returned to a ReceiveMessage request, it will not be returned on subsequent ReceiveMessage requests until the duration of the VisibilityTimeout has passed. See SetVisibilityTimeout for more information.
Note: | To view a message without locking it, in other words, without affecting the visibility state, use PeekMessage. |
Note: | Due to the distributed nature of the queue, a weighted random set of machines is sampled on a |
ReceiveMessage action requests are validated on the following:
The queue specified must exist. The URL to the queue must have been returned by a CreateQueue or ListQueues request.
VisibilityTimeout, if used, must be an integer between 0 and 86400.
NumberOfMessages, if used, must be an integer between 1 and 256.
If successful, returns Success and the message ID and message body of each available message (those not restricted by the visibility timeout setting). It returns an error response if unsuccessful.
| Name | Description | Type | Value |
|---|---|---|---|
NumberOfMessages | Optional. Specifies the maximum number of messages to return. If the number of messages in the queue is less than the value specified by NumberOfMessages, the number of messages returned is up to the number of messages in the queue. Not necessarily all the messages in the queue will be returned. If no value is provided, the default value of 1 is used. | Integer | An integer from 1 to 256. |
VisibilityTimeout | Optional. The duration, in seconds, that the returned messages are hidden from subsequent receive requests after being received. If no value is specified, the visibility timeout for the queue is used for the returned messages. The queue's visibility timeout is set using CreateQueue or SetVisibiltityTimeout. See SetVisibilityTimeout for more information.
| Integer | 0 to 86400 seconds (maximum 24 hours) |
http://queue.amazonaws.com/A29E9VSPHGOG23/queue1 ?Action=ReceiveMessage &AWSAccessKeyId=0GS7553JW74RRM612K02 &Version=2006-04-01 &Expires=2007-01-12T12:00:00Z &Signature=CN2SbNq%2B2Vw1W3lbc7wpM5gzDHE= &NumberOfMessages=2
<ReceiveMessageResponse>
<Message>
<MessageId>11YEJMCHE2DM483NGN40|3H4AA8J7EJKM0DQZR7E1|PT6DRTB278S4MNY77NJ0</MessageId>
<MessageBody>foo</MessageBody>
</Message>
<Message>
<MessageId>0MKX1FF3JB8VWS8JAV79|3H4AA8J7EJKM0DQZR7E1|PT6DRTB278S4MNY77NJ0</MessageId>
<MessageBody>bar</MessageBody>
</Message>
<ResponseStatus>
<StatusCode>Success</StatusCode>
<RequestId>b5bf2332-e983-4d3e-941a-f64c0d21f00f</RequestId>
</ResponseStatus>
</ReceiveMessageResponse>