Peek Messages operation retrieves one or more messages from the front of the queue, but does not alter the visibility of the message.
Peek Messages request may be constructed as follows. HTTPS is recommended. Replace myaccount with the name of your storage account, and
myqueue with the name of your queue:
|Method||Request URI||HTTP Version|
Emulated storage service URI
When making a request against the emulated storage service, specify the emulator hostname and Queue service port as
127.0.0.1:10001, followed by the emulated storage account name:
|Method||Request URI||HTTP Version|
The following parameters may be specified on the request URI.
||Optional. A nonzero integer value that specifies the number of messages to peek from the queue, up to a maximum of 32. By default, a single message is peeked from the queue with this operation.|
The following table describes required and optional request headers.
||Required. Specifies the authorization scheme, account name, and signature. For more information, see Authorize requests to Azure Storage.|
||Required. Specifies the Coordinated Universal Time (UTC) for the request. For more information, see Authorize requests to Azure Storage.|
||Optional. Specifies the version of the operation to use for this request. For more information, see Versioning for the Azure Storage Services.|
||Optional. Provides a client-generated, opaque value with a 1 KiB character limit that is recorded in the analytics logs when storage analytics logging is enabled. Using this header is highly recommended for correlating client-side activities with requests received by the server. For more information, see About Storage Analytics Logging and Azure Logging: Using Logs to Track Storage Requests.|
The response includes an HTTP status code, a set of response headers, and an XML response body.
A successful operation returns status code 200 (OK).
For information about status codes, see Status and Error Codes.
The response for this operation includes the following headers. The response also includes additional standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.
||This header uniquely identifies the request that was made and can be used for troubleshooting the request. For more information, see Troubleshooting API Operations.|
||Indicates the version of the Queue service used to execute the request. This header is returned for requests made against version 2009-09-19 and later.|
||A UTC date/time value generated by the service that indicates the time at which the response was initiated.|
||This header can be used to troubleshoot requests and corresponding responses. The value of this header is equal to the value of the
The response XML for the
Peek Messages operation is returned in the following format.
MessageID element is a GUID value that identifies the message in the queue. This value is assigned to the message by the Queue service and is opaque to the client.
ExpirationTime elements are represented as UTC values and formatted as described in RFC 1123.
DequeueCount element has a value of 1 the first time the message is dequeued. This value is incremented each time the message is subsequently dequeued.
DequeueCount element is returned in the response body only if the queue was created with version 2009-09-19 of the Queue service.
<QueueMessagesList> <QueueMessage> <MessageId>string-message-id</MessageId> <InsertionTime>insertion-time</InsertionTime> <ExpirationTime>expiration-time</ExpirationTime> <DequeueCount>integer</DequeueCount> <MessageText>message-body</MessageText> </QueueMessage> </QueueMessagesList>
Note that this response differs from the response for the Get Messages operation in that the response does not contain the
Response Status: HTTP/1.1 200 OK Response Headers: Transfer-Encoding: chunked Content-Type: application/xml Date: Fri, 16 Sep 2011 22:51:18 GMT Server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 Response Body: <?xml version="1.0" encoding="utf-8"?> <QueueMessagesList> <QueueMessage> <MessageId>06eba214-8107-4412-a7f6-710a9baff647</MessageId> <InsertionTime>Fri, 09 Oct 2009 18:59:54 GMT</InsertionTime> <ExpirationTime>Fri, 16 Sep 2009 18:59:54 GMT</ExpirationTime> <DequeueCount>1</DequeueCount> <MessageText>PHRlc3Q+dGhpcyBpcyBhIHRlc3QgbWVzc2FnZTwvdGVzdD4=</MessageText> </QueueMessage> </QueueMessagesList>
This operation can be performed by the account owner and by anyone with a shared access signature that has permission to perform this operation.
When a message is retrieved from the queue with
peekonly set to
true, the visibility of the message is unchanged. The message remains available to other consumers of the queue until a client retrieves the message with the Get Messages operation. The client requesting the message does not receive a pop receipt with the response and therefore cannot delete the message.
Only messages that are visible may be retrieved with the
Peek Messages operation. Note that the maximum number of messages that may be retrieved is 32.
When a message is retrieved for the first time with a call to
Get Messages, its
DequeueCount property is set to 1. If it is not deleted and is subsequently retrieved again, the
DequeueCount property is incremented. The client may use this value to determine how many times a message has been retrieved. Note that a call to
Peek Messages does not increment the value of
DequeueCount, but returns this value for the client to read.
If the numofmessages parameter is out of range, the service returns status code 400 (Bad Request), along with additional error information, as shown in the following example.
HTTP/1.1 400 One of the query parameters specified in the request URI is outside the permissible range. Connection: Keep-Alive Content-Length: 455 Via: 1.1 TK5-PRXY-22 Date: Wed, 02 May 2012 19:37:23 GMT Content-Type: application/xml Server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 x-ms-request-id: 6a03526c-ca2c-4358-a63a-b5d096988533 x-ms-version: 2011-08-18 <?xml version="1.0" encoding="utf-8"?> <Error> <Code>OutOfRangeQueryParameterValue</Code> <Message>One of the query parameters specified in the request URI is outside the permissible range. RequestId:6a03526c-ca2c-4358-a63a-b5d096988533 Time:2012-05-02T19:37:24.2438463Z </Message> <QueryParameterName>numofmessages</QueryParameterName> <QueryParameterValue>0</QueryParameterValue> <MinimumAllowed>1</MinimumAllowed> <MaximumAllowed>32</MaximumAllowed> </Error>