내보내기(0) 인쇄
모두 확장

Put Message (REST API)

업데이트 날짜: 2013년 7월

The Put Message operation adds a new message to the back of the message queue. A visibility timeout can also be specified to make the message invisible until the visibility timeout expires. A message must be in a format that can be included in an XML request with UTF-8 encoding. The encoded message can be up to 64KB in size for versions 2011-08-18 and newer, or 8KB in size for previous versions.

The Put 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:

 

Method Request URI HTTP Version

POST

https://myaccount.queue.core.windows.net/myqueue/messages?visibilitytimeout=<int-seconds>&messagettl=<int-seconds>

HTTP/1.1

Emulated Storage Service

This operation and the optional visibilitytimeout parameter are 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:

 

Method Request URI HTTP Version

POST

http://127.0.0.1:10001/devstoreaccount1/myqueue/messages?visibilitytimeout=<int-seconds>&messagettl=<int-seconds>

HTTP/1.1

For more information, see About Development Storage.

URI Parameters

The following parameters may be specified on the request URI.

 

Parameter Description

visibilitytimeout=<int=seconds>

Optional. If specified, the request must be made using an x-ms-version of 2011-08-18 or newer. If not specified, the default value is 0. 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. visibilitytimeout should be set to a value smaller than the time-to-live value.

messagettl=<int-seconds>

Optional. Specifies the time-to-live interval for the message, in seconds. The maximum time-to-live allowed is 7 days. If this parameter is omitted, the default time-to-live is 7 days.

timeout

Optional. The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for Queue Service Operations.

Request Headers

The following table describes required and optional request headers.

 

Request Header Description

Authorization

Required. Specifies the authentication scheme, account name, and signature. For more information, see Authentication for the Windows 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 Windows Azure Storage Services.

x-ms-version

Optional. Specifies the version of the operation to use for this request. For more information, see Versioning for the Blob, Queue, and Table Services in Windows Azure.

x-ms-client-request-id

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 Windows Azure Logging: Using Logs to Track Storage Requests.

Request Body

The body of the request contains the message data in the following XML format. Note that the message content must be in a format that may be encoded with UTF-8.

<QueueMessage>
    <MessageText>message-content</MessageText>
</QueueMessage>

Sample Request

Request:
POST https://myaccount.queue.core.windows.net/messages?visibilitytimeout=30&timeout=30 HTTP/1.1

Headers:
x-ms-version: 2011-08-18
x-ms-date: Tue, 30 Aug 2011 01:03:21 GMT
Authorization: SharedKey myaccount:sr8rIheJmCd6npMSx7DfAY3L//V3uWvSXOzUBCV9wnk=
Content-Length: 100

Body:
<QueueMessage>
<MessageText>PHNhbXBsZT5zYW1wbGUgbWVzc2FnZTwvc2FtcGxlPg==</MessageText>
</QueueMessage>

The response includes an HTTP status code and a set of response headers.

Status Code

A successful operation returns status code 201 (Created).

For information about status codes, see Status and Error Codes.

Response Headers

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.

 

Request Header Description

x-ms-request-id

This header uniquely identifies the request that was made and can be used for troubleshooting the request. For more information, see Troubleshooting API Operations.

x-ms-version

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.

Date

A UTC date/time value generated by the service that indicates the time at which the response was initiated.

Response Body

None.

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 optional visibility timeout specifies the time that the message will be invisible. After the timeout expires, the message will become visible. If a visibility timeout is not specified, the default value of 0 is used.

The optional message time-to-live specifies how long a message will remain in the queue. The message will be deleted from the queue when the time-to-live period expires.

If the message is too large, the service returns status code 400 (Bad Request).

Microsoft는 MSDN 웹 사이트에 대한 귀하의 의견을 이해하기 위해 온라인 설문 조사를 진행하고 있습니다. 참여하도록 선택하시면 MSDN 웹 사이트에서 나가실 때 온라인 설문 조사가 표시됩니다.

참여하시겠습니까?
표시:
© 2014 Microsoft