Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid 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.

  • 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.

  • 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.

  • 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.

Type: String

Valid Values: VisibilityTimeout | Policy | MaximumMessageSize | MessageRetentionPeriod

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.

  • VisibilityTimeout—An integer from 0 to 43200 (12 hours).

  • 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.

  • MaximumMessageSize—An integer from 1024 bytes (1KB) up to 65536 bytes (64KB). The default for this attribute is 8192 (8KB).

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

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 195004372649/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%2F195004372649%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%
22%2F195004372649%2FtestQueue%22%7D%5D%7D
&Timestamp=2009-05-06T16%3A57%3A31.000Z
&AWSAccessKeyId=0AZAVD7PQ3DCC3452ZG2
&Signature=%2Bd7ZlPIdnb%2BhpEna2TgfwQjfGF8%3D

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

{
    "Version":"2008-10-17",
    "Id":"/195004372649/testQueue/SQSDefaultPolicy",
    "Statement":  [
        {
        "Sid":"Queue1ReceiveMessage",
        "Effect":"Allow",
        "Principal":{"AWS":"*"},
        "Action":"SQS:ReceiveMessage",
        "Resource":"/195004372649/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=0GS7553JW74RRM612K02EXAMPLE
&SignatureVersion=2
&Signature=Dqlp3Sd6ljTUA9Uf6SGtEExwUQEXAMPLE

Sample Response

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

Related Actions