Modifies the period after which a consumed message that remains in the Inactive state can be consumed again.
Authorization
By default, only Alibaba Cloud accounts can call this operation. RAM users can call this operation only after these RAM users are granted related permissions. The following table describes the authorization information of this operation. For more information, see Permission policies and examples.
Name | Value |
---|---|
API | ChangeMessageVisibility |
Action | mns:ChangeMessageVisibility |
Resource | acs:mns:$region:$accountid:/queues/$queueName/messages |
Request
A request consists of the following parts:
- Request line
PUT /queues/$queueName/messages?receiptHandle=<receiptHandle>&visibilityTimeout=<visibilitytimeout> HTTP/1.1
- URI parameters
Parameter Type Required Example Description ReceiptHandle String Yes MbZj6wDWli+QEauMZc8ZRv37sIW2iJKq3M9Mx/KSbkJ0 The receipt handle that was returned when the message was last consumed. For more information, see ReceiveMessage. VisibilityTimeout Integer Yes 50 The period after which the message can be consumed again. Unit: seconds. - Operation-specific request headers
None.
- Request Body
None.
Response
A response consists of the following parts:
- HTTP Status Code
HTTP/1.1 200 OK
- Operation-specific response headers
None.
- Response Body
Parameter Type Example Description ReceiptHandle String TbZj6wDWli+9CEauMZc8ZRv37sIW2iJKq3M9Mx/TS1 The receipt handle that is returned after the value of the VisibilityTimeout
parameter is modified. This receipt handle can be used to delete and modify the message that is in the Inactive state and remains valid before the time that is specified by theNextVisibleTime
parameter.NextVisibleTime Long 1250700979298000 The next time when the message can be consumed. 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.
Examples
Sample requests
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+FIEXA****
Sample success responses
HTTP/1.1 200 OK
x-mns-request-id:512B2A634403E52B1956****
x-mns-version: 2015-06-06
<?xml version="1.0" encoding="UTF-8"?>
<ChangeVisibility xmlns="http://mns.aliyuncs.com/doc/v1/">
<ReceiptHandle>TbZj6wDWli+9CEauMZc8ZRv37sIW2iJKq3M9Mx/TS1</ReceiptHandle >
<NextVisibleTime>1250700979298000</NextVisibleTime>
</ChangeVisibility>
Error codes
Error code | Error message | HTTP status code | Description |
---|---|---|---|
InvalidArgument | The value of Element should between Low and High seconds/bytes. | 400 | The error message returned because the value of the parameter is invalid. You must specify a valid value as prompted. |
ReceiptHandleError | The receipt handle you provide is not valid. | 400 | The error message returned because the ReceiptHandle parameter is invalid. |
QueueNotExist | The queue name you provided is not exist. | 404 | The error message returned because the specified queue does not exist. Create a queue. |
MessageNotExist | The receipt handle you provided has expired. | 404 | The error message returned because you have not consumed a message within the invisibility period and the receipt handle of the message has expired. Consume messages within the invisibility period or specify a longer invisibility period. |