All Products
Search
Document Center

BatchDeleteMessage

Last Updated: Jul 23, 2019

Description

This interface is used to delete multiple messages at a maximum of 16 in a message queue in batches by inputting the corresponding ReceiptHandle for each.

This interface is recommended to used along with BatchReceiveMessage for higher efficiency.

The batch operation result may contain both successful and failed sub-requests.The HTTP status code is 204 only when all sub-requests are successful.If some sub-requests failed, you need to check the error information of every sub-request in the response.

Request

A request mainly includes the following parts:

  • Request line

    DELETE /queues/$queueName/messages HTTP/1.1

  • Special URI Parameter

    None.

  • Special Request Header

    None. See Public Request Headers.

  • Request Body

    Request Body is in XML format. XML contains the ReceiptHandles of multiple messages.

Response

The returned message includes 3 parts: returned status line, HTTP header and message body.

  • HTTP Status Code

    HTTP/1.1 204 NoContent

  • Special Response Header

    None. See Public Returned Headers.

  • Response Body

    None.

Special Error

Error Code Error Message Status Code
QueueNotExist The queue name you provided is not exist. 404
InvalidArgument The value of Element should between Low and High seconds/bytes. 400
ReceiptHandleError The receipt handle you provide is not valid. 400

Request example:

  1. DELETE /queues/$queueName/messages HTTP/1.1
  2. Host: $AccountId.mns.cn-hangzhou.aliyuncs.com
  3. Date: Wed, 28 May 2012 22:32:00 GMT
  4. x-mns-version: 2015-06-06
  5. Authorization: MNS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE
  6. <?xml version="1.0” encoding=”UTF-8” ?>
  7. <ReceiptHandles xmlns=”http://mns.aliyuncs.com/doc/v1/”>
  8. <ReceiptHandle>1-ODU4OTkzNDU5My0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
  9. <ReceiptHandle>1-ODU4OTkzNDU5NC0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
  10. <ReceiptHandle>1-ODU4OTkzNDU5NS0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
  11. </ReceiptHandles>

Response example:

  • Delete all messages successful.

    1. HTTP/1.1 204 NoContent
    2. x-mns-request-id:512B2A634403E52B1956133E
    3. x-mns-version: 2015-06-06
  • Some messages failed to delete.

    1. HTTP/1.1 404
    2. Connection:close
    3. Content-Type=text/xml;charset=utf-8
    4. Content-Length:500
    5. x-mns-request-id:512B2A634403E52B1956133E
    6. x-mns-version: 2015-06-06
    7. <?xml version="1.0” encoding=”UTF-8” ?>
    8. <Errors xmlns=”http://mns.aliyuncs.com/doc/v1/”>
    9. <Error>
    10. <ErrorCode>MessageNotExist</ErrorCode>
    11. <ErrorMessage>Message not exist.</ErrorMessage>
    12. <ReceiptHandle>1-ODU4OTkzNDU5My0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
    13. </Error>
    14. <Error>
    15. <ErrorCode>MessageNotExist</ErrorCode>
    16. <ErrorMessage>Message not exist.</ErrorMessage>
    17. <ReceiptHandle>1-ODU4OTkzNDU5NC0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
    18. </Error>
    19. </Errors>