Queries a message. The PeekMessage operation is different from the ReceiveMessage operation. After you call the PeekMessage operation, the message is still in the Active state and can be queried or consumed. However, after you call the ReceiveMessage operation, the status of the message becomes Inactive and the message cannot be queried or consumed for a period that is specified by the VisibilityTimeout parameter.

Request

A request consists of the following parts:

  • Request line

    GET /$queueName/messages? peekonly=true HTTP/1.1

  • URI parameter

    To query a message in a queue, set peekonly to true in the request. This way, the request does not change the status of the message.

  • Operation-specific request headers

    None. For information about common request parameters, see Common parameters.

  • Request Body

    None.

Response

A response consists of a status line, HTTP headers, and a response body.

  • HTTP Status Code

    HTTP/1.1 200 OK

  • Operation-specific response headers

    None. For information about common response parameters, see Common parameters.

  • Response Body
    The response is in the XML format. It contains the message body and other parameters of the message.
    Parameter Description
    MessageId The ID of the message. Each message ID is unique in the queue.
    MessageBody The body of the message.
    MessageBodyMD5 The MD5 hash of the message body.
    EnqueueTime The time when the message was sent to the queue. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.
    FirstDequeueTime The time when the message was consumed for the first time. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC. If the value of the DequeueCount parameter is 0, the value of this parameter is the same as that of the EnqueueTime parameter.
    DequeueCount The number of times that the message has been consumed.
    Priority The priority of the message.

Special Error

Error code Error message HTTP status code
QueueNotExist The queue name you provided is not exist. 404
MessageNotExist Message not exist. 404
  • Sample requests
        GET  /$queueName/messages? peekonly=true HTTP/1.1
        Host: $AccountId.mqs-cn-hangzhou.aliyuncs.com
        Date: Wed, 28 May 2012 22:32:00 GMT
        x-mqs-version: 2014-07-08
        Authorization: MQS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE            
  • Sample success responses
        HTTP/1.1 200 OK
        Connection:close
        Content-Type=text/xml;charset=utf-8
        Content-Length:500
        x-mqs-request-id:512B2A634403E52B1956133E 
        x-mqs-version: 2015-06-06
    
        <? xml version="1.0" encoding="UTF-8"? >
        <Message xmlns="http://mqs.aliyuncs.com/doc/v1/">
            <MessageId>D6D5F7C9C12D14A4-1-14D953EFC72-200000004</MessageId>
            <MessageBodyMD5>F9360F391579E71CA77BC5D50242FCF4</MessageBodyMD5>
            <MessageBody>This is a test message</MessageBody>
            <EnqueueTime>1250700979248</EnqueueTime>
            <FirstDequeueTime>1250700979348</FirstDequeueTime >
            <DequeueCount>5</DequeueCount>
            <Priority>8<Priority>
        </Message>