Amazon Simple Queue Service
API Reference (API Version 2011-10-01)
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...

GetQueueAttributes

Description

The GetQueueAttributes action returns one or all attributes of a queue.

Calling GetQueueAttributes with the AttributeName set to All returns values for each API version as indicated in the following table.

Attribute2008-01-012009-02-012011-10-01
VisibilityTimeout
ApproximateNumberOfMessages
ApproximateNumberOfMessagesNotVisible 
CreatedTimestamp 
LastModifiedTimestamp 
QueueArn 
MaximumMessageSize 
MessageRetentionPeriod 
Policy 
DelaySeconds  
ApproximateNumberOfMessagesDelayed  
[Note]Note

Going forward, new attributes might be added. If you are writing code that calls this action, we recommend that you structure your code so that it can handle new attributes gracefully.

[Note]Note

Some API operations take lists of parameters. These lists are specified using the param.n notation. Values of n are integers starting from 1. For example, a parameter list with two elements looks like this:

&Attribute.1=this
&Attribute.2=that

Request Parameters

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

NameDescriptionRequired

AttributeName.n

The attribute you want to get.

  • All—returns all values.

  • ApproximateNumberOfMessages—returns the approximate number of visible messages in a queue. For more information, see Resources Required to Process Messages in the Amazon SQS Developer Guide.

  • ApproximateNumberOfMessagesNotVisible—returns the approximate number of messages that are not timed-out and not deleted. For more information, see Resources Required to Process Messages in the Amazon SQS Developer Guide.

  • ApproximateNumberOfMessagesDelayed—returns the approximate number of messages that are not visible because you have set a positive delay value on the queue.

  • VisibilityTimeout—returns the visibility timeout for the queue. For more information about visibility timeout, see Visibility Timeout in the Amazon SQS Developer Guide.

  • CreatedTimestamp—returns the time when the queue was created (epoch time in seconds).

  • LastModifiedTimestamp—returns the time when the queue was last changed (epoch time in seconds).

  • Policy—returns the queue's policy.

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

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

  • QueueArn—returns the queue's Amazon resource name (ARN).

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

Type: String

Valid values: All | ApproximateNumberOfMessages | ApproximateNumberOfMessagesNotVisible | VisibilityTimeout | CreatedTimestamp | LastModifiedTimestamp | Policy | MaximumMessageSize | MessageRetentionPeriod | QueueArn | OldestMessageAge | DelaySeconds | ApproximateNumberOfMessagesDelayed

Default: None

Yes

Response Elements

The following table lists the response elements the GetQueueAttributes action returns in addition to the common response elements all actions return (for more information, see Responses section in the Amazon SQS Developer Guide.

NameDescription

Attribute

An element containing each attribute's information.

Ancestor: GetQueueAttributesResult

Children:

  • Name—The attribute name you requested.

  • Value—The value for the requested attribute. The CreatedTimestamp and the LastModifiedTimestamp are each returned as an integer representing the epoch time in seconds.

Special Errors

The following table lists the special errors the GetQueueUrl 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

The following example Query request gets all the attribute values for the specified queue.

Sample Request

http://sqs.us-east-1.amazonaws.com/123456789012/testQueue/
?Action=GetQueueAttributes
&AttributeName.1=All
&Version=2009-02-01
&SignatureMethod=HmacSHA256
&Expires=2009-04-18T22%3A52%3A43PST
&AWSAccessKeyId=0GS7553JW74RRM612K02EXAMPLE
&SignatureVersion=2
&Signature=Dqlp3Sd6ljTUA9Uf6SGtEExwUQEXAMPLE

Sample Response

<GetQueueAttributesResponse>
  <GetQueueAttributesResult>
    <Attribute>
      <Name>VisibilityTimeout</Name>
      <Value>30</Value>
    </Attribute>
    <Attribute>
      <Name>ApproximateNumberOfMessages</Name>
      <Value>0</Value>
    </Attribute>
    <Attribute>
      <Name>ApproximateNumberOfMessagesNotVisible</Name>
      <Value>0</Value>
    </Attribute>
    <Attribute>
      <Name>CreatedTimestamp</Name>
      <Value>1286771522</Value>
    </Attribute>
    <Attribute>
      <Name>LastModifiedTimestamp</Name>
      <Value>1286771522</Value>
    </Attribute>
    <Attribute>
      <Name>QueueArn</Name>
      <Value>arn:aws:sqs:us-east-1:123456789012:qfoo</Value>
    </Attribute>
    <Attribute>
      <Name>MaximumMessageSize</Name>
      <Value>8192</Value>
    </Attribute>
    <Attribute>
      <Name>MessageRetentionPeriod</Name>
      <Value>345600</Value>
    </Attribute>
  </GetQueueAttributesResult>
  <ResponseMetadata>
    <RequestId>1ea71be5-b5a2-4f9d-b85a-945d8d08cd0b</RequestId>
  </ResponseMetadata>
</GetQueueAttributesResponse>

The following example Query request gets two attribute values for the specified queue.

Sample Request

http://sqs.us-east-1.amazonaws.com/123456789012/testQueue/
?Action=GetQueueAttributes
&Action=GetQueueAttributes
&Version=2011-10-01
&AttributeName.1=VisibilityTimeout
&AttributeName.2=DelaySeconds
&SignatureMethod=HmacSHA256
&Expires=2011-08-18T22%3A52%3A43PST
&AWSAccessKeyId=0GS7553JW74RRM612K02EXAMPLE
&SignatureVersion=2
&Signature=Dqlp3Sd6ljTUA9Uf6SGtEExwUQEXAMPLE

Sample Response

<GetQueueAttributesResponse>
  <GetQueueAttributesResult>
    <Attribute>
      <Name>VisibilityTimeout</Name>
      <Value>30</Value>
    </Attribute>
    <Attribute>
      <Name>DelaySeconds</Name>
      <Value>0</Value>
    </Attribute>
</GetQueueAttributesResponse>

Related Actions