Method: Aws::SQS::Client#receive_message
- Defined in:
- lib/aws-sdk-sqs/client.rb
#receive_message(params = {}) ⇒ Types::ReceiveMessageResult
Retrieves one or more messages (up to 10), from the specified queue. Using the ‘WaitTimeSeconds` parameter enables long-poll support. For more information, see [Amazon SQS Long Polling] in the *Amazon Simple Queue Service Developer Guide*.
Short poll is the default behavior where a weighted random set of machines is sampled on a ‘ReceiveMessage` call. Thus, only the messages on the sampled machines are returned. If the number of messages in the queue is small (fewer than 1,000), you most likely 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. If this happens, repeat the request.
For each message returned, the response includes the following:
-
The message body.
-
An MD5 digest of the message body. For information about MD5, see [RFC1321].
-
The ‘MessageId` you received when you sent the message to the queue.
-
The receipt handle.
-
The message attributes.
-
An 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 Simple Queue Service Developer Guide*.
You can provide the ‘VisibilityTimeout` parameter in your request. The parameter is 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 Simple Queue Service Developer Guide*.
A message that isn’t deleted or a message whose visibility isn’t 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.
<note markdown=“1”> In the future, new attributes might be added. If you write code that calls this action, we recommend that you structure your code so that it can handle new attributes gracefully.
</note>
[1]: docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-long-polling.html [2]: www.ietf.org/rfc/rfc1321.txt [3]: docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-queue-message-identifiers.html [4]: docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html
1447 1448 1449 1450 |
# File 'lib/aws-sdk-sqs/client.rb', line 1447 def (params = {}, = {}) req = build_request(:receive_message, params) req.send_request() end |