GetQueueAttributes

Description

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

[Important]Important

Before the 2007-05-01 release introduced the GetQueueAttributes action, you retrieved the visibility timeout by using the GetVisibilityTimeout action. As of the 2008-01-01 release of Amazon SQS, the GetVisibilityTimeout action is no longer supported.

[Note]Programming 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. Use this notation for Query requests. For SOAP requests add another element for each additional parameter value. For example, in Query a parameter list looks like this:

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

In SOAP, a parameter list looks like this:

<Attribute>this<Attribute>
<Attribute>that<Attribute>

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 Request Parameters Common to All Actions).

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.

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

  • VisibilityTimeout—returns the default visibility timeout for the queue. For more information about visibility timeout, see Visibility Timeout.

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

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

  • Policy—returns the queue's policy created using SetQueueAttributes.

Type: String

Valid values: All | ApproximateNumberOfMessages | ApproximateNumberOfMessagesNotVisible | VisibilityTimeout | CreatedTimestamp | LastModifiedTimestamp | Policy

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 Structure of a Successful Response).

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 GetQueueAttributes action returns in addition to the common errors all actions return (for more information, see Errors Common to all Actions).

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://queue.amazonaws.com/123456789012/testQueue/
?Action=GetQueueAttributes
&AttributeName=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>32</Value>
    </Attribute>
    <Attribute>
      <Name>ApproximateNumberOfMessages</Name>
      <Value>0</Value>
    </Attribute>
    <Attribute>
      <Name>ApproximateNumberOfMessagesNotVisible</Name>
      <Value>1</Value>
    </Attribute>
    <Attribute>
      <Name>CreatedTimestamp</Name>
      <Value>1238098969</Value>
    </Attribute>
    <Attribute>
      <Name>LastModifiedTimestamp</Name>
      <Value>1238099106</Value>
    </Attribute>
  </GetQueueAttributesResult>
  <ResponseMetadata>
    <RequestId>
      cbd6e5cb-b4f1-46fb-8356-3b4705290606
    </RequestId>
  </ResponseMetadata>
</GetQueueAttributesResponse>

Related Actions