All Products
Document Center


Last Updated: Jul 23, 2019


This interface is used by the consumer to view a message. Different from ReceiveMessage, PeekMessage does not change the message status. If the message is acquired by PeekMessage, the message is still in Active status and can be viewed or consumed. However, if the message is acquired by ReceiveMessage, the message changes 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 HTTP/1.1

  • URI parameter

    peekonly=true indicates that this request is used only to view the first message in the queue and will not change the message status

  • Special Request Header

    None. See Public Request Headers.

  • Request Body



The returned message includes three 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 body and attributes of the message 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 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. <Message xmlns=””>
  9. <MessageId>D6D5F7C9C12D14A4-1-14D953EFC72-200000004</MessageId>
  10. <MessageBodyMD5>F9360F391579E71CA77BC5D50242FCF4</MessageBodyMD5>
  11. <MessageBody>This is a test message</MessageBody>
  12. <EnqueueTime>1250700979248</EnqueueTime>
  13. <FirstDequeueTime>1250700979348</FirstDequeueTime >
  14. <DequeueCount>5</DequeueCount>
  15. <Priority>8<Priority>
  16. </Message>