Amazon Simple Queue Service
API Reference (API Version 2012-11-05)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Did this page help you?  Yes | No |  Tell us about it...

SetQueueAttributes

Description

The SetQueueAttributes action sets one attribute of a queue per request. When you change a queue's attributes, the change can take up to 60 seconds to propagate throughout the SQS system.

Request Parameters

The following table lists the special request parameters the SetQueueAttributes action uses in addition to the common request parameters all actions use (for more information, see Common Query Parameters).

NameDescriptionRequired

Attribute.Name

The name of the attribute you want to set.

  • DelaySeconds—The time in seconds that the delivery of all messages in the queue will be delayed.

  • MaximumMessageSize—The limit of how many bytes a message can contain before Amazon SQS rejects it.

  • MessageRetentionPeriod—The number of seconds Amazon SQS retains a message.

  • Policy—The formal description of the permissions for a resource. For more information about Policy, see Basic Policy Structure in the Amazon SQS Developer Guide.

  • ReceiveMessageWaitTimeSeconds—Long poll support (integer from 1 to 20). Specifies the duration, in seconds, that the ReceiveMessage action call will wait until a message is in the queue to include in the response, as opposed to returning an empty response if a message is not yet available to return. The default of short poll support occurs when this attribute is not configured or is configured with a value of 0. For more information, see Amazon SQS Long Poll

  • VisibilityTimeout—The length of time, in seconds, that a message received from a queue will be invisible to other receiving components when they ask to receive messages. For more information about VisibilityTimeout, see Visibility Timeout in the Amazon SQS Developer Guide.

Type: String

Valid Values: DelaySeconds | MaximumMessageSize | MessageRetentionPeriod | Policy | ReceiveMessageWaitTimeSeconds | VisibilityTimeout

Default: None

Yes

Attribute.Value

The value of the attribute you want to set. To delete a queue's access control policy, set the policy to "".

Constraints: Constraints are specific for each value.

  • DelaySeconds—An integer from 0 to 900 (15 minutes). The default for this attribute is 0.

  • MaximumMessageSize—An integer from 1024 bytes (1 KiB) up to 262144 bytes (256 KiB). The default for this attribute is 262144 (256 KiB).

  • MessageRetentionPeriod—Integer representing seconds, from 60 (1 minute) to 1209600 (14 days). The default for this attribute is 345600 (4 days).

  • Policy—A valid form-url-encoded policy. For more information about policy structure, see Basic Policy Structure in the Amazon SQS Developer Guide. For more information about form-url-encoding, see http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1.

  • ReceiveMessageWaitTimeSeconds—An integer from 0 to 20 (seconds). The default for this attribute is 0.

  • VisibilityTimeout—An integer from 0 to 43200 (12 hours). The default for this attribute is 30 seconds.

Default: Varies according to attribute

Yes

Response Elements

The response contains no special elements besides the common elements in all successful responses. For more information, see Responses section in the Amazon SQS Developer Guide.

Special Errors

The following table lists the special errors the SetQueueAttributes action returns in addition to the common errors all actions return. For more information, see Common Errors.

ErrorDescriptionHTTP Status Code

InvalidAttributeName

Unknown attribute

400

Examples

Sample Request with Policy

The following example Query request sets a policy that gives all users ReceiveMessage permission for the queue named testQueue.

http://sqs.us-east-1.amazonaws.com/123456789012/testQueue/
?Action=SetQueueAttributes
&Version=2009-02-01
&Attribute.Name=Policy
&Attribute.Value=%7B%22Version%22%3A%222008-10-17%22%2C%22Id%22
%3A%22%2F123456789012%2FtestQueue%2FSQSDefaultPolicy%22%2C%22Stat
ement%22%3A%5B%7B%22Sid%22%3A%22Queue1ReceiveMessage%22%2C%22Effe
ct%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22AWS%22%3A%22*%22%7D
%2C%22Action%22%3A%22SQS%3AReceiveMessage%22%2C%22Resource%22%3A%
22arn%3Aaws%3Aaws%3Asqs%3Aus%2Deast%2D1%3A123456789012%3AtestQueue%22%7D%5D%7D
&Timestamp=2009-05-06T16%3A57%3A31.000Z
&AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE
&Signature=%2Bd7ZlPIdnb%2BhpEna2TgfwQjfGF8%3D

The above policy value is form-url-encoded from the following text:

{
    "Version":"2008-10-17",
    "Id":"/123456789012/testQueue/SQSDefaultPolicy",
    "Statement":  [
        {
        "Sid":"Queue1ReceiveMessage",
        "Effect":"Allow",
        "Principal":{"AWS":"*"},
        "Action":"SQS:ReceiveMessage",
        "Resource":"arn:aws:sqs:us-east-1:123456789012:testQueue"
        }
    ]    
}

For more examples of policies, see Amazon SQS Policy Examples in the Amazon SQS Developer Guide.

Sample Request with VisibilityTimeout

The following example Query request sets the visibility timeout to 35 seconds for the queue named 123456789012/testQueue.

http://sqs.us-east-1.amazonaws.com/123456789012/testQueue/
?Action=SetQueueAttributes
&Attribute.Name=VisibilityTimeout
&Attribute.Value=35
&Version=2009-02-01
&SignatureMethod=HmacSHA256
&Expires=2009-04-18T22%3A52%3A43PST
&AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE
&SignatureVersion=2
&Signature=Dqlp3Sd6ljTUA9Uf6SGtEExwUQEXAMPLE

Sample Response

<SetQueueAttributesResponse>
    <ResponseMetadata>
        <RequestId>
            e5cca473-4fc0-4198-a451-8abb94d02c75
        </RequestId>
    </ResponseMetadata>
</SetQueueAttributesResponse>