SendMessage
Description
This interface is used to send a message to the specified message queue. A common message can be consumed by the consumer immediately after being sent to a message queue. The producer can set the DelaySeconds parameter when sending the message to consume later (the typical scenario is a scheduled task). The initial status of a message with the DelaySeconds value(>0) is Delayed. The message can not be consumed till its status turns to Active after its DelaySeconds time expires.
Tip:
The priority of the DelaySeconds parameter specified upon message sending is higher than the DelaySeconds attribute of the delayed message queue. That means, when the values of the two DelaySeconds attributes are different, the value of the DelaySeconds parameter specified upon message sending takes precedence.
Request
A request mainly includes the following parts:
Request line
POST /queues/$queueName/messages HTTP/1.1
Special Request Header
None. See Public Request Headers.
Request Body
Request Body is in XML format. XML contains the attributes for creating message.
Parameter Name | Description | Parameter Value |
---|---|---|
MessageBody | Required. Message body | UTF-8 character set |
DelaySeconds | Optional. A delay time after which a message can be consumed, measured in seconds. | An integer between 0 and 604800 (7 days). The default value is 0. |
Priority | Optional. Priority of a specified message. A message with a higher priority is more likely to be consumed earlier. | The value ranges from 1 to 16 (the value 1 indicates the highest priority). The default value is 8. |
Response
The returned message includes 3 parts: returned status line, HTTP header and message body.
HTTP Status Code
HTTP/1.1 201 Created
Special Response Header
None. See Public Returned Headers.
Response Body
The returned result is in XML format. The MessageId and MessageBodyMD5 sub-elements of the message are returned.
Parameter Name | Description |
---|---|
MessageId | Message ID, which is unique in one queue. |
MessageBodyMD5 | MD5 value of the message body |
Special Error
Error Code | Error Message | Status Code |
---|---|---|
QueueNotExist | The queue name you provided is not exist. | 404 |
MalformedXML | The XML you provided was not well-formed. | 400 |
InvalidArgument | The value of Element should between Low and High seconds/bytes. | 400 |
Request example:
POST /queues/$queueName/messages HTTP/1.1
Host: $AccountId.mns.cn-hangzhou.aliyuncs.com
Date: Wed, 18 Mar 2012 12:00:00 GMT
Content-Length:500
Content-Type:text/xml;charset=utf-8
x-mns-version: 2015-06-06
Authorization: MNS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE
<?xml version="1.0” encoding=”UTF-8” ?>
<Message xmlns=”http://mns.aliyuncs.com/doc/v1/”>
<MessageBody>Base64 Encoded Result</MessageBody>
<DelaySeconds>60</DelaySeconds>
<Priority>1</Priority>
</Message>
Response example:
HTTP/1.1 201Created
Connnection:close
Content-Length:120
Content-Type:text/xml;charset=utf-8
x-mns-request-id:512B2A634403E52B1956133E
x-mns-version: 2015-06-06
<?xml version="1.0” encoding=”UTF-8” ?>
<Message xmlns=”http://mns.aliyuncs.com/doc/v1/”>
<MessageId>
5F290C926D472878-2-14D9529A8FA-200000001
</MessageId>
<MessageBodyMD5>
C5DD56A39F5F7BB8B3337C6D11B6D8C7
</MessageBodyMD5>
</Message>
BatchSendMessage
Description
This interface is used to send messages to the specified message queue in batches. A maximum of 16 messages can be sent in one BatchSendMessage operation.
A common message can be consumed by the consumer immediately after being sent to a message queue. The producer can set the DelaySeconds parameter when sending the message to consume later(the typical scenario is a scheduled task). The initial status of a message with the DelaySeconds value(>0) is Delayed. The message can not be consumed till its status turns to Active after its DelaySeconds time expires in this status.
Tip:
The priority of the DelaySeconds parameter specified upon message sending is higher than the DelaySeconds attribute of the delayed message queue. That means, when the values of the two DelaySeconds attributes are different, the value of the DelaySeconds parameter specified upon message sending takes precedence.
Request
A request mainly includes the following parts:
Request line
POST /queues/$queueName/messages HTTP/1.1
Special Request Header
None. See “Public Request Headers”.
Request Body
Request Body is in XML format. XML contains the attributes for creating messages.
Parameter Name | Description | Parameter Value |
---|---|---|
MessageBody | Required. Message body | UTF-8 character set |
DelaySeconds | Optional. A delay time after which a message can be consumed, measured in seconds | An integer between 0 and 604800 (7 days). The default value is 0 |
Priority | Optional. Priority of a specified message.A message with a higher priority is more likely to be consumed earlier | The value ranges from 1 to 16 (the value 1 indicates the highest priority). The default value is 8 |
Response
The returned message includes 3 parts: returned status line, HTTP header and message body.
HTTP Status Code
HTTP/1.1 201 Created
Special Response Header
None. See Public Returned Headers.
Response Body
The return result is in XML format. The MessageId and MessageBodyMD5 sub-elements of multiple messages are returned.
Parameter Name | Description |
---|---|
MessageId | Message ID, which is unique in one queue. |
MessageBodyMD5 | MD5 value of the message body |
Special Error:
Error Code | Error Message | Status Code |
---|---|---|
QueueNotExist | The queue name you provided is not exist. | 404 |
MalformedXML | The XML you provided was not well-formed. | 400 |
InvalidArgument | The value of Element should between Low and High seconds/bytes. | 400 |
Request example:
POST /queues/$queueName/messages HTTP/1.1
Host: $AccountId.mns.cn-hangzhou.aliyuncs.com
Date: Wed, 18 Mar 2012 12:00:00 GMT
Content-Length:500
Content-Type:text/xml;charset=utf-8
x-mns-version: 2015-06-06
Authorization: MNS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE
<?xml version="1.0” encoding=”UTF-8” ?>
<Messages xmlns=”http://mns.aliyuncs.com/doc/v1/”>
<Message>
<MessageBody>Message1 Base64 Encoded Result</MessageBody>
<DelaySeconds>60</DelaySeconds>
<Priority>1</Priority>
</Message>
<Message>
<MessageBody>Message2 Base64 Encoded Result</MessageBody>
<DelaySeconds>60</DelaySeconds>
<Priority>1</Priority>
</Message>
</Messages>
Response example:
HTTP/1.1 201Created
Connnection:close
Content-Length:120
Content-Type:text/xml;charset=utf-8
x-mns-request-id:512B2A634403E52B1956133E
x-mns-version: 2015-06-06
<?xml version="1.0” encoding=”UTF-8” ?>
<Messages xmlns=”http://mns.aliyuncs.com/doc/v1/”>
<Message>
<MessageId>5F290C926D472878-2-14D9529A8FA-200000001</MessageId>
<MessageBodyMD5>C5DD56A39F5F7BB8B3337C6D11B6D8C7</MessageBodyMD5>
</Message>
<Message>
<MessageId>5F290C926D472878-2-14D9529A8FA-200000002</MessageId>
<MessageBodyMD5>377AC5283D8765C9CEE4E0EA353DFC17</MessageBodyMD5>
</Message>
</Messages>
ReceiveMessage
Description
This interface is used by the consumer to consume a message in a message queue. The ReceiveMessage operation will change the acquired message to Inactive status. The Inactive duration is determined by the VisibilityTimeout attribute of the queue (for details, see CreateQueue Interface).
After the message is successfully consumed, the DeleteMessage interface should be called to delete the message in the VisibilityTimeout period. Otherwise, the message will be reset to Active status and consumable.
Request
A request mainly includes the following parts:
Request line
GET /queues/$queueName/messages?waitseconds=10 HTTP/1.1
Special URI Parameter
Parameter Name | Description | Required? |
---|---|---|
waitseconds | Maximum polling waiting time① of the ReceiveMessage request, measured in seconds | Optional |
Note:
If the ReceiveMessage request carries the waitseconds parameter, the polling waiting time of the ReceiveMessage request is specified by waitseconds. If the waitseconds parameter is not specified, the polling waiting time is specified by the PollingWaitSeconds attribute of the queue (see CreateQueue Interface).
Special Request Header
None. See Public Request Headers.
Request Body
None.
Response
The returned message includes 3 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 returned 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 |
ReceiptHandle | Temporary handle generated for the acquired message, which is used to delete or modify the message in Inactive status and is valid before NextVisibleTime. |
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 |
NextVisibleTime | Time when a message can be consumed again, 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 |
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:
GET /queues/$queueName/messages HTTP/1.1
Host: $AccountId.mns.cn-hangzhou.aliyuncs.com
Date: Wed, 28 May 2012 22:32:00 GMT
x-mns-version: 2015-06-06
Authorization: MNS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE
Response example:
HTTP/1.1 200 OK
Connection:close
Content-Type=text/xml;charset=utf-8
Content-Length:500
x-mns-request-id:512B2A634403E52B1956133E
x-mns-version: 2015-06-06
<?xml version="1.0” encoding=”UTF-8” ?>
<Message xmlns=”http://mns.aliyuncs.com/doc/v1/”>
<MessageId>5F290C926D472878-2-14D9529A8FA-200000001</MessageId>
<ReceiptHandle>1-ODU4OTkzNDU5My0xNDMyNzI3ODI3LTItOA==</ReceiptHandle>
<MessageBodyMD5>C5DD56A39F5F7BB8B3337C6D11B6D8C7</MessageBodyMD5>
<MessageBody>This is a test message</MessageBody>
<EnqueueTime>1250700979248</EnqueueTime>
<NextVisibleTime>1250700799348</NextVisibleTime>
<FirstDequeueTime>1250700779318</FirstDequeueTime >
<DequeueCount>1</DequeueCount >
<Priority>8</Priority>
</Message>
BatchReceiveMessage
Description
This interface is used by the consumer to consume messages in a queue in batches. A maximum of 16 messages can be acquired in one BatchReceiveMessage operation.This operation will change the acquired messages to Inactive status. The Inactive duration is determined by the VisibilityTimeout attribute of the queue (for details, see CreateQueue Interface).
After the messages are successfully consumed, the DeleteMessage interface should be called to delete the acquired messages in the VisibilityTimeout period. Otherwise, the acquired messages will be reset to Active status and consumable again.
Request
A request mainly includes the following parts:
Request line
GET /queues/$queueName/messages?numOfMessages=16&waitseconds=10 HTTP/1.1
Special URI Parameter
Parameter Name | Description | Required? |
---|---|---|
numOfMessages | Maximum number of messages that can be acquired for the current BatchReceiveMessage operation. | Required |
waitseconds | Maximum polling waiting time① of the ReceiveMessage request, measured in seconds. | Optional |
Note:
The polling waiting time of the BatchReceiveMessage request is specified by its preset waitseconds, or the PollingWaitSeconds attribute of the queue without presetting waitseconds (refer to CreateQueue Interface).
Special Request Header
None. See Public Request Headers.
Request Body
None.
Response
The returned message includes 3 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 bodies and attributes of multiple messages are returned.
Parameter Name | Description |
---|---|
MessageId | Message ID, which is unique in one queue |
ReceiptHandle | Temporary handle generated for the acquired message, which is used to delete or modify the message in Inactive status and is valid before NextVisibleTime. |
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 |
NextVisibleTime | Time when a message can be consumed again, 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 |
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:
GET /queues/$queueName/messages?numOfMessages=16 HTTP/1.1
Host: $AccountId.mns.cn-hangzhou.aliyuncs.com
Date: Wed, 28 May 2012 22:32:00 GMT
x-mns-version: 2015-06-06
Authorization: MNS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE
Response example:
HTTP/1.1 200 OK
Connection:close
Content-Type=text/xml;charset=utf-8
Content-Length:500
x-mns-request-id:512B2A634403E52B1956133E
x-mns-version: 2015-06-06
<?xml version="1.0” encoding=”UTF-8” ?>
<Messages xmlns=”http://mns.aliyuncs.com/doc/v1/”>
<Message>
<MessageId>5F290C926D472878-2-14D9529A8FA-200000001</MessageId>
<ReceiptHandle>1-ODU4OTkzNDU5My0xNDMyNzI3ODI3LTItOA==</ReceiptHandle>
<MessageBodyMD5>C5DD56A39F5F7BB8B3337C6D11B6D8C7</MessageBodyMD5>
<MessageBody>This is a test message</MessageBody>
<EnqueueTime>1250700979248</EnqueueTime>
<NextVisibleTime>1250700799348</NextVisibleTime>
<FirstDequeueTime>1250700779318</FirstDequeueTime >
<DequeueCount>1</DequeueCount>
<Priority>8</Priority>
</Message>
<Message>
<ReceiptHandle>1-ODU4OTkzNDU5My0xNDMyNzI3MjQwLTEtOA==</ReceiptHandle>
<MessageBodyMD5>C5DD56A39F5F7BB8B3337C6D11B6D8C7</MessageBodyMD5>
<MessageBody>This is a test message</MessageBody>
<EnqueueTime>1250700979252</EnqueueTime>
<NextVisibleTime>1250700799350</NextVisibleTime>
<FirstDequeueTime>1250700779330</FirstDequeueTime >
<DequeueCount>1</DequeueCount>
<Priority>8</Priority>
</Message>
</Messages>
DeleteMessage
Description
This interface is used to delete a consumed message. The consumer needs to use the ReceiptHandle returned by the previous consumption as the parameter to locate the message. This operation can be executed successfully only before NextVisibleTime. The ReceiptHandle becomes invalid as the messages turns to Active after the NextVisibleTime expires. You have to acquire a new ReceiptHandle again if you want to execute the deletion.
Request
A request mainly includes the following parts:
Request line
DELETE /queues/$queueName/messages?ReceiptHandle=<receiptHandle> HTTP/1.1
Special URI Parameter
Parameter Name | Description | Required? |
---|---|---|
ReceiptHandle | ReceiptHandle returned by the previous consumption. For details, see ReceiveMessage Interface. | Required |
Special Request Header
None. See Public Request Headers.
Request Body
None.
Response
The returned message includes 3 parts: returned status line, HTTP header and message body.
HTTP Status Code
HTTP/1.1 204 NoContent
Special Response Header
None. See Public Returned Headers.
Response Body
None.
Special Error
Error Code | Error Message | Status Code |
---|---|---|
QueueNotExist | The queue name you provided is not exist. | 404 |
InvalidArgument | The value of Element should between Low and High seconds/bytes. | 400 |
ReceiptHandleError | The receipt handle you provide is not valid. | 400 |
Request example:
DELETE /queues/$queueName/messages?ReceiptHandle=MbZj6wDWli+QEauMZc8ZRv37sIW2iJKq3M9Mx/KSbkJ0 HTTP/1.1
Host: $AccountId.mns.cn-hangzhou.aliyuncs.com
Date: Wed, 28 May 2012 22:32:00 GMT
x-mns-version: 2015-06-06
Authorization: MNS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE
Response example:
HTTP/1.1 204 NoContent
x-mns-request-id:512B2A634403E52B1956133E
x-mns-version: 2015-06-06
BatchDeleteMessage
Description
This interface is used to delete multiple messages at a maximum of 16 in a message queue in batches by inputting the corresponding ReceiptHandle for each.
This interface is recommended to used along with BatchReceiveMessage for higher efficiency.
The batch operation result may contain both successful and failed sub-requests. The HTTP status code is 204 only when all sub-requests are successful.If some sub-requests failed, you need to check the error information of every sub-request in the response.
Request
A request mainly includes the following parts:
Request line
DELETE /queues/$queueName/messages HTTP/1.1
Special URI Parameter
None.
Special Request Header
None. See Public Request Headers.
Request Body
Request Body is in XML format. XML contains the ReceiptHandles of multiple messages.
Response
The returned message includes 3 parts: returned status line, HTTP header and message body.
HTTP Status Code
HTTP/1.1 204 NoContent
Special Response Header
None. See Public Returned Headers.
Response Body
None.
Special Error
Error Code | Error Message | Status Code |
---|---|---|
QueueNotExist | The queue name you provided is not exist. | 404 |
InvalidArgument | The value of Element should between Low and High seconds/bytes. | 400 |
ReceiptHandleError | The receipt handle you provide is not valid. | 400 |
Request example:
DELETE /queues/$queueName/messages HTTP/1.1
Host: $AccountId.mns.cn-hangzhou.aliyuncs.com
Date: Wed, 28 May 2012 22:32:00 GMT
x-mns-version: 2015-06-06
Authorization: MNS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE
<?xml version="1.0” encoding=”UTF-8” ?>
<ReceiptHandles xmlns=”http://mns.aliyuncs.com/doc/v1/”>
<ReceiptHandle>1-ODU4OTkzNDU5My0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
<ReceiptHandle>1-ODU4OTkzNDU5NC0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
<ReceiptHandle>1-ODU4OTkzNDU5NS0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
</ReceiptHandles>
Response example:
Delete all messages successful.
HTTP/1.1 204 NoContent
x-mns-request-id:512B2A634403E52B1956133E
x-mns-version: 2015-06-06
Some messages failed to delete.
HTTP/1.1 404
Connection:close
Content-Type=text/xml;charset=utf-8
Content-Length:500
x-mns-request-id:512B2A634403E52B1956133E
x-mns-version: 2015-06-06
<?xml version="1.0” encoding=”UTF-8” ?>
<Errors xmlns=”http://mns.aliyuncs.com/doc/v1/”>
<Error>
<ErrorCode>MessageNotExist</ErrorCode>
<ErrorMessage>Message not exist.</ErrorMessage>
<ReceiptHandle>1-ODU4OTkzNDU5My0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
</Error>
<Error>
<ErrorCode>MessageNotExist</ErrorCode>
<ErrorMessage>Message not exist.</ErrorMessage>
<ReceiptHandle>1-ODU4OTkzNDU5NC0xNDM1MTk3NjAwLTItNg==</ReceiptHandle>
</Error>
</Errors>
PeekMessage
Description
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.
Request
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
None.
Response
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:
GET /queues/$queueName/messages?peekonly=true HTTP/1.1
Host: $AccountId.mns.cn-hangzhou.aliyuncs.com
Date: Wed, 28 May 2012 22:32:00 GMT
x-mns-version: 2015-06-06
Authorization: MNS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE
Response example:
HTTP/1.1 200 OK
Connection:close
Content-Type=text/xml;charset=utf-8
Content-Length:500
x-mns-request-id:512B2A634403E52B1956133E
x-mns-version: 2015-06-06
<?xml version="1.0" encoding="UTF-8"?>
<Message xmlns=”http://mns.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>
BatchPeekMessage
Description
This interface is used by the consumer to view messages in batches at a maximum of 16 at a time. Different from BatchReceiveMessage, BatchPeekMessage does not change the message status. If messages are acquired by BatchPeekMessage, the messages are still in Active status and can be viewed or consumed. However, if the messages are acquired by BatchReceiveMessage, the messages change to Inactive status and cannot be viewed or consumed within the VisibilityTimeout period.
Request
A request mainly includes the following parts:
Request line
GET /queues/$queueName/messages?peekonly=true&numOfMessages=16 HTTP/1.1
Special URI Parameter
Parameter Name | Description | Required? |
---|---|---|
peekonly=true | Indicates that this request is used only to view the first message in the queue and will not change the message status. | Required |
numOfMessages | Maximum number of messages that can be viewed for the current BatchPeekMessage operation. | Required |
Special Request Header
None. See Public Request Headers.
Request Body
None.
Response
The returned message includes 3 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 bodies and attributes of multiple messages 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:
GET /queues/$queueName/messages?peekonly=true&numOfMessages=16 HTTP/1.1
Host: $AccountId.mns.cn-hangzhou.aliyuncs.com
Date: Wed, 28 May 2012 22:32:00 GMT
x-mns-version: 2015-06-06
Authorization: MNS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE
Response example:
HTTP/1.1 200 OK
Connection:close
Content-Type=text/xml;charset=utf-8
Content-Length:500
x-mns-request-id:512B2A634403E52B1956133E
x-mns-version: 2015-06-06
<?xml version="1.0" encoding="UTF-8"?>
<Messages xmlns=”http://mns.aliyuncs.com/doc/v1/”>
<Message>
<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>
<Message>
<MessageId>D6D5F7C9C12D14A4-1-14D953EFC72-200000005</MessageId>
<MessageBodyMD5>F9360F391579E71CA77BC5D50242FCF4</MessageBodyMD5>
<MessageBody>This is a test message</MessageBody>
<EnqueueTime>1250700979250</EnqueueTime>
<FirstDequeueTime>1250700979352</FirstDequeueTime >
<DequeueCount>5</DequeueCount>
<Priority>8<Priority>
</Message>
</Messages>
ChangeMessageVisibility
Description
This interface is used to modify the next consumable time of a message which has been consumed and is still in Inactive status. After VisibilityTimeout of the message is modified successfully, a new ReceiptHandle is returned.
Request
A request mainly includes the following parts:
Request line
PUT /queues/$queueName/messages?receiptHandle=<receiptHandle>&visibilityTimeout=<visibilitytimeout> HTTP/1.1
URI parameter
Parameter Name | Description | Required? |
---|---|---|
ReceiptHandle | ReceiptHandle returned by the previous consumption. For details, see ReceiveMessage Interface | Required |
VisibilityTimeout | Interval between the current time and the next consumable time, measured in seconds | Required |
Special Request Header
None. See Public Request Headers.
Request Body
None.
Response
The returned message includes 3 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
Parameter Name | Description |
---|---|
ReceiptHandle | Temporary handle returned after VisibilityTimeout of the message is modified, which is used to delete or modify the message in Inactive status and is valid before NextVisibleTime. |
NextVisibleTime | Time when a message can be consumed again, represented in milliseconds that have elapsed since 1970-1-1 0:00. |
Special Error
Error Code | Error Message | Status Code |
---|---|---|
QueueNotExist | The queue name you provided is not exist. | 404 |
InvalidArgument | The value of Element should between Low and High seconds/bytes. | 400 |
MessageNotExist | Message not exist. | 404 |
Request example:
PUT /queues/$queueName/messages
?receiptHandle=MbZj6wDWli+QEauMZc8ZRv37sIW2iJKq3M9Mx/KSbkJ0&visibilityTimeout=50 HTTP/1.1
Host: $AccountId.mns.cn-hangzhou.aliyuncs.com
Date: Wed, 28 May 2012 22:32:00 GMT
x-mns-version: 2015-06-06
Authorization: MNS 15B4D3461F177624206A:xQE0diMbLRepdf3YB+FIEXAMPLE
Response example:
HTTP/1.1 200OK
x-mns-request-id:512B2A634403E52B1956133E
x-mns-version: 2015-06-06
<?xml version="1.0" encoding="UTF-8" ?>
<Message xmlns="http://mns.aliyuncs.com/doc/v1/">
<ReceiptHandle>
TbZj6wDWli+9CEauMZc8ZRv37sIW2iJKq3M9Mx/TS1
</ReceiptHandle >
<NextVisibleTime>1250700979298000</NextVisibleTime>
</Message>