阅读832 返回首页    go 阿里云


批量删除消息__队列接口规范_API使用手册_消息服务-阿里云

描述

该接口用于批量删除队列多条消息,最多可以删除16条消息,每条消息需要传入相应的ReceiptHandle。建议此接口与 BatchReceiveMessage 搭配使用,效率会更高。批量操作的结果可能同时包含成功和失败的子请求。只有全部子请求都成功时,HTTP状态码才是204。当部分失败发生时,用户需检查响应中每个消息的错误信息。

Request

Request的构造主要由以下几个部分组成:

  • 请求行

    DELETE /queues/$queueName/messages HTTP/1.1

  • 特有Request Header

    无,请参考 调用方式/公共参数

  • Request Body

    Request Body为 XML 格式,其中包含多条消息的 ReceiptHandle。

Response

返回消息由返回状态行,HTTP头和消息体三部分组成。

  • HTTP Status Code

    HTTP/1.1 204 NoContent

  • 特有Response Header

    无,请参考 调用方式/公共参数

  • Response Body

Special Error

错误代码 错误消息 状态码
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

请求示例:

  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="https://mns.aliyuncs.com/doc/v1/">
  8. <ReceiptHandle>1-ODU4OTkzNDU5My0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
  9. <ReceiptHandle>1-ODU4OTkzNDU5NC0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
  10. <ReceiptHandle>1-ODU4OTkzNDU5NS0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
  11. </ReceiptHandles>

返回示例:

  • 正常删除所有消息

    1. HTTP/1.1 204 No Content
    2. x-mns-request-id:512B2A634403E52B1956133E
    3. x-mns-version: 2015-06-06
  • 部分消息删除失败

    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="https://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>

最后更新:2016-11-23 17:16:09

  上一篇:go 批量消费消息__队列接口规范_API使用手册_消息服务-阿里云
  下一篇:go 查看消息__队列接口规范_API使用手册_消息服务-阿里云