DeleteMessage#

Description#

Deletes the specified message from the queue.

Request Syntax#

POST / HTTP/1.1
Content-type: application/json

{
    "QueueUrl": "string",
    "ReceiptHandle": "string"
}

Request Parameters#

  • QueueUrl — The URL of the queue from which the message has to be deleted.

    • Type: String

    • Required: Yes

  • ReceiptHandle — The ID of the to-be-deleted message received when calling ReceiveMessage.

    • Type: String

    • Required: Yes

Response Syntax#

HTTP/1.1 200
Content-type: application/json

{
    "Success": boolean
}

Response Elements#

  • Success — The result of the deletion operation.

    • Type: Boolean

Errors#

  • InvalidParameterValue — The invalid ID of the message to be deleted.

  • ReceiptHandleIsInvalid — The specified ID of the message to be deleted is invalid.

Examples#

boto3
import boto3

session = boto3.Session(
   aws_access_key_id="<AWS_ACCESS_KEY_ID>",
   aws_secret_access_key="<AWS_SECRET_ACCESS_KEY>",
   region_name="",
)

sqs_client = session.client(
   'sqs',
   endpoint_url='https://sqs.ru-msk.k2.cloud/'
)

# Receive message
response = sqs_client.receive_message(
    QueueUrl='https://sqs.ru-msk.k2.cloud/123456789012/my-queue'
)

if 'Messages' in response:
    message = response['Messages'][0]

    # Delete message
    sqs_client.delete_message(
        QueueUrl='https://sqs.ru-msk.k2.cloud/123456789012/my-queue',
        ReceiptHandle=message['ReceiptHandle']
    )
aws-cli
 aws sqs --endpoint https://sqs.ru-msk.k2.cloud/ delete-message \\
     --queue-url https://sqs.ru-msk.k2.cloud/123456789012/my-queue \\
     --receipt-handle "AQEB..."