GET on MessageQueue

The GET action on a MessageQueue endpoint does one of two things:

To retrieve one or more messages from the queue, you must append the static message ID front to the queue URL (see the example below). Messages are retrieved from the front of the queue, and the message body and message ID of each message is returned. Messages returned by this action stay in the queue until deleted. However, once a message is returned to a GET request on a MessageQueue endpoint, it will not be returned on subsequent GET on MessageQueue requests until the duration of the optional VisibilityTimeout has passed. If you do not specify VisibilityTimeout in the request, the overall visibility timeout for the queue is used. A default visibility timeout of 30 seconds is set when you create the queue, and you can also set the visibility timeout for the queue by using PUT on MessageQueue.

Note:

To view a message without locking it, in other words, without affecting the visibility state, use GET on Message.

Note:

Due to the distributed nature of the queue, a weighted random set of machines is sampled when you retrieve the messages. 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 one or two messages per call. You can always peek on any specific message in the queue by using GET on Message, because Amazon SQS knows which machine the message lives on.

To get the visibility timeout, you must not append the static message ID front to the queue URL.

GET requests on MessageQueue are validated on the following:

If successful, returns Success and either the message ID and message body of each available message (those not restricted by the visibility timeout setting). Or, the action returns Success and the visibility timeout (if that's how you're using the action). The action returns 400 (fail) and an error if unsuccessful.

NameDescriptionTypeValue
NumberOfMessagesSpecifies the maximum number of messages to return. If the number of messages in the queue is less than the value specified by NumberOfMessages, the maximum number of messages returned is 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.Optional. Use when retrieving messages from the queue.An integer from 1 to 256.
VisibilityTimeoutThe duration, in seconds, that the returned messages are hidden from subsequent GET on MessageQueue requests after being retrieved. If no value is specified, the visibility timeout for the queue is used for the returned messages. See SetVisibilityTimeout for more information.Optional. Use when retrieving messages from the queue.Integer from 0 to 86400 seconds (maximum 24 hours)

The following examples show how to retrieve messages from a queue and how to get the visibility timeout for the queue.

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 POST or GET on QueueService request.