Receiving and deleting a message in Amazon SQS - Amazon Simple Queue Service
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Receiving and deleting a message in Amazon SQS

After you send messages to an Amazon SQS queue, you have the option to receive and delete them. When requesting messages from a queue, you cannot specify individual messages. Instead, you determine the maximum number of messages you wish to retrieve, up to a limit of 10.

Amazon SQS operates as a distributed system, which can occasionally result in an empty response when retrieving messages from a queue with few messages. If this happens, simply rerun your request. To optimize message retrieval and minimize empty responses, consider using long polling. Long polling delays the response until a message becomes available or the poll times out, reducing unnecessary polling costs and improving efficiency.

Messages are not automatically deleted after retrieval because Amazon SQS ensures that you do not lose access to a message due to processing failures, such as issues with your application or network disruptions. To permanently remove a message from the queue, you must explicitly send a delete request after processing the message to confirm successful receipt and handling.

When messages are retrieved via the Amazon SQS console, they are immediately made visible again for re-retrieval. This default behavior ensures messages are not inadvertently lost during manual operations but can lead to repeated processing. In automated environments, adjust the visibility timeout setting to control how long a message remains invisible to other consumers after being retrieved. This setting is crucial for coordinating message processing across multiple consumers and ensuring that messages are processed only once.

For more detailed operations on receiving and deleting messages, see the Amazon SQS API Reference Guide. This guide offers comprehensive information on API endpoints, including parameters that manage complex message handling scenarios effectively.

To receive and delete a message using the console
  1. Open the Amazon SQS console at https://console.amazonaws.cn/sqs/.

  2. In the navigation pane, choose Queues.

  3. On the Queues page, select a queue, and then choose Send and receive messages.

    Console with the Send and receive messages button highlighted.
  4. On the Send and receive messages page, choose Poll for messages.

    Amazon SQS begins to poll for messages in the queue. The progress bar on the right side of the Receive messages section displays the duration of polling.

    The Messages section displays a list of the received messages. For each message, the list displays the message ID, Sent date, Size, and Receive count.

  5. To delete messages, choose the messages that you want to delete, and then choose Delete.

  6. In the Delete Messages dialog box, choose Delete.