ReceiveMessage (SOAP)

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 call. Therefore, only the messages on the sampled machines will be returned. If the number of messages in the queue is small (less than 1000), it is likely you will get 1 or 2 messages per ReceiveMessage call. You can always peek on any specific message in the queue using the PeekMessage action with the MessageID parameter, because SQS knows which machine the message lives on.

ReceiveMessage action requests are validated on the following:

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.

NameDescriptionTypeValue
NumberOfMessagesOptional. Specifies the maximum number of messages to return. If the number of messages in the queue is less than 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.IntegerAn integer from 1 to 256.
VisibilityTimeoutOptional. 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 value is set using CreateQueue or SetVisibilityTimeout. See SetVisibilityTimeout for more information. Integer0 to 86400 seconds (maximum 24 hours)
ErrorDescription
InvalidParameterValueThe value specified for VisibilityTimeout or NumberOfMessages is out of range.
InvalidURIThe URL for the queue is not valid, or is not a URL returned by a CreateQueue or ListQueues request.