tencent cloud

Feedback

Batch Deleting Messages

Last updated: 2024-01-03 10:20:36

    API Description

    This API is used to batch delete up to 16 consumed messages. The consumer needs to use the ReceiptHandle obtained after the last consumption as a parameter to locate the messages to be deleted.
    This operation can be successfully performed only before NextVisibleTime. After NextVisibleTime elapses, the message will return to the Active status, and ReceiptHandle will become invalid, making it impossible to delete the message. In this case, the message needs to be consumed again to get a new ReceiptHandle. When a message is consumed by multiple consumers concurrently, if the message is deleted by one of the consumers, other consumers can no longer get it.
    The public/private domain names for API requests can be copied from Queue Service > API Request Address in the TDMQ for CMQ console. A sample address is as follows:
    Public network address: https://cmq-gz.publicXXX.tencenttdmq.com
    Private network address: http://gz.mqadapter.cmq.tencentyun.com
    Note:
    The API call URL varies by region.
    Whenever downstream traffic is generated from using the public domain name, traffic fees will be charged (even during the beta test period). Therefore, we strongly recommend you use the private domain name to avoid traffic fees.

    Input Parameters

    The list below contains only the API request parameters. Other parameters can be found in Common Request Parameters.
    Parameter
    Required
    Type
    Description
    queueName
    Yes
    String
    Queue name, which must be unique under the same account in the same region. It can contain up to 64 letters, digits, and hyphens and must begin with a letter.
    receiptHandle.n
    Yes
    String
    Message handler returned from the last consumption. For ease of use, n can start from either 0 or 1, but the values must be consecutive. For example, two messages to be deleted can be represented by receiptHandle.0,receiptHandle.1 or receiptHandle.1, receiptHandle.2.

    Output Parameters

    Parameter
    Type
    Description
    code
    Int
    0: Success. 4420: The QPS has reached the limit. 4440: The queue does not exist. 6010: Failed to delete some messages. 6020: Failed to delete all messages. For the descriptions of other returned values, see Common Error Codes.
    message
    String
    Error message.
    requestId
    String
    Request ID generated by the server, which can be submitted to the backend for troubleshooting when an internal server error occurs.
    errorList
    Array
    List of deletion failures. Each element indicates one message deletion failure and the cause.
    errorList is defined as follows:
    Parameter
    Type
    Description
    code
    Int
    0: Success. others: Error. For more information, see Common Error Codes.
    message
    String
    Error message.
    receiptHandle
    String
    Handler of the message failed to be deleted.

    Error Codes

    For more information, see Common Error Codes.

    Samples

    Input:
    https://domain/v2/index.php?Action=BatchDeleteMessage &queueName=test-queue-123 &receiptHandle.1=3423452345 &receiptHandle.1=4364564575 &<<a href="">Common request parameters</a>>
    Output (when the operation completely succeeded):
    {
    "code" : 0,
    "message" : "",
    "requestId":"14534664555"
    }
    Output (when the operation partially failed):
    {
    "code" : 6010,
    "message" : "delete message partially failed",
    "requestId":"14534664555",
    "errorList":
    [
    {
    "code" : 4430,
    "message" : "invalid receiptHandle",
    "receiptHandle":"4364564575"
    }
    ]
    }
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support