Updated: August 4, 2015
This operation was introduced with version 2011-08-18 of the Queue service API. The Update Message operation updates the visibility timeout of a message. You can also use this operation to update the contents of a message. A message must be in a format that can be included in an XML request with UTF-8 encoding, and the encoded message can be up to 64KB in size.
The Update Message 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:
This operation is supported for SDK 1.6 and newer versions.
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:
The following parameters may be specified on the request URI.
Required. Specifies the new visibility timeout value, in seconds, relative to server time. The new value must be larger than or equal to 0, and cannot be larger than 7 days. The visibility timeout of a message cannot be set to a value later than the expiry time. A message can be updated until it has been deleted or has expired.
Optional. The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for Queue Service Operations.
The following table describes required and optional request headers.
Required. Specifies the authentication scheme, account name, and signature. For more information, see Authentication for the Azure Storage Services.
Date or x-ms-date
Required. Specifies the Coordinated Universal Time (UTC) for the request. For more information, see Authentication for the Azure Storage Services.
Requires 2011-08-18 or newer. 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 KB 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 and a set of response headers.
A successful operation returns status code 204 (No Content).
For information about status codes, see Status and Error Codes.
The response for this operation includes the following headers. The response may also include 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.
The pop receipt of the queue message.
A UTC date/time value that represents when the message will be visible on the queue.
This operation can be performed by the account owner and by anyone with a shared access signature that has permission to perform this operation.
The following request extends the visibility of a queue message by 30 seconds and updates its content.
PUT https://myaccount.queue.core.windows.net/myqueue/messages/663d89aa-d1d9-42a2-9a6a-fcf822a97d2c?popreceipt=AgAAAAEAAAApAAAAGIw6Q29bzAE%3d&visibilitytimeout=30&timeout=30 HTTP/1.1
The request is sent with the following headers:
x-ms-version: 2011-08-18 x-ms-date: Mon, 29 Aug 2011 17:17:21 GMT Authorization: SharedKey myaccount:batcrWZ35InGCZeTUFWMdIQiOZPCW7UEyeGdDOg7WW4= Content-Length: 75
The request is sent with the following XML body:
<QueueMessage> <MessageText>new-message-content</MessageText> </QueueMessage>
After the request has been sent, the following response is returned:
HTTP/1.1 204 No Content Content-Length: 0 Server: Windows-Azure-Queue/1.0 Microsoft-HTTPAPI/2.0 x-ms-request-id: df34a7dd-3cbe-4206-a586-d6de3cf225a7 x-ms-version: 2011-08-18 x-ms-popreceipt: AwAAAAIAAAApAAAAINtMQ29bzAEBAAAA x-ms-time-next-visible: Mon, 29 Aug 2011 17:17:51 GMT Date: Mon, 29 Aug 2011 17:17:21 GMT
An Update Message operation will fail if the specified message does not exist in the queue, or if the specified pop receipt does not match the message.
A pop receipt is returned by the Get Messages operation or the Update Message operation. Pop receipts remain valid until one of the following events occurs:
The message has expired.
The message has been deleted using the last pop receipt received either from Get Messages or Update Message.
The invisibility time has elapsed and the message has been dequeued by a Get Messages request. When the invisibility time elapses, the message becomes visible again. If it is retrieved by another Get Messages request, the returned pop receipt can be used to delete or update the message.
The message has been updated with a new visibility timeout. When the message is updated, a new pop receipt will be returned.
The Update Message operation can be used to continually extend the invisibility of a queue message. This functionality can be useful if you want a worker role to “lease” a queue message. For example, if a worker role calls Get Messages and recognizes that it needs more time to process a message, it can continually extend the message’s invisibility until it is processed. If the worker role were to fail during processing, eventually the message would become visible again and another worker role could process it.