Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Message Queue
  • Getting started
    • Quick start
    • Supported tools
    • Code samples
      • Node.js
      • PHP
      • JMS
      • Laravel
      • Terraform
  • Step-by-step instructions
    • Overview
    • Creating a new message queue
    • Sending messages
    • Receiving and deleting messages
    • Deleting a message queue
  • Concepts
    • Overview
    • Message queues
    • Messages
    • Deduplication
    • Visibility timeout
    • Long Polling
    • Dead Letter Queue
    • Delay queues
    • Quotas and limits
  • Access management
  • Pricing policy
  • Yandex Message Queue API
    • Overview
    • Queue
      • CreateQueue
      • DeleteQueue
      • GetQueueAttributes
      • GetQueueUrl
      • ListQueues
      • PurgeQueue
      • SetQueueAttributes
    • Message
      • ChangeMessageVisibility
      • ChangeMessageVisibilityBatch
      • DeleteMessage
      • DeleteMessageBatch
      • ReceiveMessage
      • SendMessage
      • SendMessageBatch
    • Data types
      • BatchResultErrorEntry
      • ChangeMessageVisibilityBatchRequestEntry
      • ChangeMessageVisibilityBatchResultEntry
      • DeleteMessageBatchRequestEntry
      • DeleteMessageBatchResultEntry
      • Message
      • MessageAttributeValue
      • SendMessageBatchRequestEntry
      • SendMessageBatchResultEntry
    • Common errors
  • Questions and answers
  1. Step-by-step instructions
  2. Receiving and deleting messages

Receiving and deleting messages

    After messages are received and processed, they should be deleted from a queue:

    AWS CLI

    Run the following command in the terminal:

    $ aws sqs receive-message \
                --endpoint https://message-queue.api.cloud.yandex.net/ \
                --queue-url https://message-queue.api.cloud.yandex.net/aoegtvhtp8ob9rqq8sto/000000000000002p01jp/sample-queue
    {
        "Messages": [
            {
                "MessageId": "948de7-9ec8d787-cbf3465c-c",
                "ReceiptHandle": "EAEggbjIg_8sKAM",
                "MD5OfBody": "ed076287532e86365e841e92bfc50d8c",
                "Body": "Hello World!",
                "Attributes": {
                    "ApproximateFirstReceiveTimestamp": "1545927269377",
                    "ApproximateReceiveCount": "1",
                    "SentTimestamp": "1545922344034"
                }
            }
        ]
    }
    

    To delete a message, use the receipt-handle parameter value of the received message. Run the following command in the terminal:

    $ aws sqs receive-message \
                --endpoint https://message-queue.api.cloud.yandex.net/ \
                --queue-url https://message-queue.api.cloud.yandex.net/aoegtvhtp8ob9rqq8sto/000000000000002p01jp/sample-queue \
                --receipt-handle EAEggbjIg_8sKAM
    
    Language
    Careers
    Privacy policy
    Terms of use
    © 2021 Yandex.Cloud LLC