All Products
Document Center


Last Updated: Jul 23, 2019


This interface is used by the consumer to view messages in batches at a maximum of 16 at a time. Different from BatchReceiveMessage, BatchPeekMessage does not change the message status. If messages are acquired by BatchPeekMessage, the messages are still in Active status and can be viewed or consumed. However, if the messages are acquired by BatchReceiveMessage, the messages change to Inactive status and cannot be viewed or consumed within the VisibilityTimeout period.


A request mainly includes the following parts:

  • Request line

    GET /queues/$queueName/messages?peekonly=true&numOfMessages=16 HTTP/1.1

  • Special URI Parameter

Parameter Name Description Required?
peekonly=true Indicates that this request is used only to view the first message in the queue and will not change the message status Required
numOfMessages Maximum number of messages that can be viewed for the current BatchPeekMessage operation Required
  • Special Request Header

    None. See Public Request Headers.

  • Request Body



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

  • HTTP Status Code

    HTTP/1.1 200 OK

  • Special Response Header

    None. See Public Returned Headers.

  • Response Body

    The return result is in XML format. The message bodies and attributes of multiple messages are returned.

Parameter Name Description
MessageId Message ID, which is unique in one queue
MessageBody Message body
MessageBodyMD5 MD5 value of the message body
EnqueueTime Time when a message is sent to the queue, represented in milliseconds that have elapsed since 1970-1-1 0:00
FirstDequeueTime Time when a message is consumed for the first time, represented in milliseconds that have elapsed since 1970-1-1 0:00. If DequeueCount is 0, it is the same as EnqueueTime of the message
DequeueCount Total consumption times of a message
Priority Priority of a message

Special Error

Error Code Error Message Status Code
QueueNotExist The queue name you provided is not exist. 404
MessageNotExist Message not exist. 404

Request example:

  1. GET /queues/$queueName/messages?peekonly=true&numOfMessages=16 HTTP/1.1
  2. Host: $
  3. Date: Wed, 28 May 2012 22:32:00 GMT
  4. x-mns-version: 2015-06-06
  5. Authorization: MNS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE

Response example:

  1. HTTP/1.1 200 OK
  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. <Messages xmlns=””>
  9. <Message>
  10. <MessageId>D6D5F7C9C12D14A4-1-14D953EFC72-200000004</MessageId>
  11. <MessageBodyMD5>F9360F391579E71CA77BC5D50242FCF4</MessageBodyMD5>
  12. <MessageBody>This is a test message</MessageBody>
  13. <EnqueueTime>1250700979248</EnqueueTime>
  14. <FirstDequeueTime>1250700979348</FirstDequeueTime >
  15. <DequeueCount>5</DequeueCount>
  16. <Priority>8<Priority>
  17. </Message>
  18. <Message>
  19. <MessageId>D6D5F7C9C12D14A4-1-14D953EFC72-200000005</MessageId>
  20. <MessageBodyMD5>F9360F391579E71CA77BC5D50242FCF4</MessageBodyMD5>
  21. <MessageBody>This is a test message</MessageBody>
  22. <EnqueueTime>1250700979250</EnqueueTime>
  23. <FirstDequeueTime>1250700979352</FirstDequeueTime >
  24. <DequeueCount>5</DequeueCount>
  25. <Priority>8<Priority>
  26. </Message>
  27. </Messages>