Deletes multiple messages from a queue.
Name | Value |
API | BatchDeleteMessage |
Action | mns:BatchDeleteMessage |
Resource | acs:mns:$region:$accountid:/queues/$queueName/messages |
Description
You can call this operation to delete multiple messages from a queue. A maximum of 16 messages can be deleted at a time. The receipt handle of each message that you want to delete must be included in the request.
To improve efficiency, you can call the BatchReceiveMessage and BatchDeleteMessage operations to receive and delete multiple messages at a time. A request that is used to delete multiple messages includes multiple subrequests, and some subrequests may fail. The HTTP status code 204 is returned only if all subrequests succeed. If some subrequests fail, you must check the error message in each response.
Request
A request consists of the following parts:
- Request line
DELETE /queues/$queueName/messages HTTP/1.1
- Operation-specific request headers
None.
- Request Body
The request body is in the XML format. The receipt handle of each message that you want to delete must be included in the request.
Response
A response consists of the following parts:
- HTTP Status Code
HTTP/1.1 204 NoContent
- Operation-specific response headers
None.
- Response Body
None.
Examples
Sample requests
DELETE /queues/$queueName/messages HTTP/1.1
Host: $AccountId.mns.cn-hangzhou.aliyuncs.com
Date: Wed, 28 May 2012 22:32:00 GMT
x-mns-version: 2015-06-06
Authorization: MNS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXA****
<? xml version="1.0" encoding="UTF-8"? >
<ReceiptHandles xmlns="http://mns.aliyuncs.com/doc/v1/">
<ReceiptHandle>1-ODU4OTkzNDU5My0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
<ReceiptHandle>1-ODU4OTkzNDU5NC0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
<ReceiptHandle>1-ODU4OTkzNDU5NS0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
</ReceiptHandles>
Sample responses
- Sample success responses when all messages are deleted
HTTP/1.1 204 No Content x-mns-request-id:512B2A634403E52B1956**** x-mns-version: 2015-06-06
- Sample responses when some messages fail to be deleted
HTTP/1.1 404 Connection:close Content-Type=text/xml;charset=utf-8 Content-Length:500 x-mns-request-id:512B2A634403E52B1956**** x-mns-version: 2015-06-06 <? xml version="1.0" encoding="UTF-8"? > <Errors xmlns="http://mns.aliyuncs.com/doc/v1/"> <Error> <ErrorCode>MessageNotExist</ErrorCode> <ErrorMessage>Message not exist. </ErrorMessage> <ReceiptHandle>1-ODU4OTkzNDU5My0xNDM1MTk3NjAwLTItNg==</ReceiptHandle> </Error> <Error> <ErrorCode>MessageNotExist</ErrorCode> <ErrorMessage>Message not exist. </ErrorMessage> <ReceiptHandle>1-ODU4OTkzNDU5NC0xNDM1MTk3NjAwLTItNg==</ReceiptHandle> </Error> </Errors>
Special Error
Error code | Error message | HTTP 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 |