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

GetQueueAttributes

Description

Gets attributes for the specified queue. The following attributes are supported:

  • 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.
  • 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).
  • ApproximateNumberOfMessagesDelayed - returns the approximate number of messages that are pending to be added to the queue.
  • DelaySeconds - returns the default delay on the queue in seconds.
  • ReceiveMessageWaitTimeSeconds - returns the time for which a ReceiveMessage call will wait for a message to arrive.
  • RedrivePolicy - returns the parameters for dead letter queue functionality of the source queue. For more information about RedrivePolicy and dead letter queues, see Using Amazon SQS Dead Letter Queues in the Amazon SQS Developer Guide.

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

Some API actions 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

For information about the common parameters that all actions use, see Common Parameters.

AttributeName.member.N

A list of attributes to retrieve information for.

Type: String list

Valid Values: Policy | VisibilityTimeout | MaximumMessageSize | MessageRetentionPeriod | ApproximateNumberOfMessages | ApproximateNumberOfMessagesNotVisible | CreatedTimestamp | LastModifiedTimestamp | QueueArn | ApproximateNumberOfMessagesDelayed | DelaySeconds | ReceiveMessageWaitTimeSeconds | RedrivePolicy

Required: No

QueueUrl

The URL of the Amazon SQS queue to take action on.

Type: String

Required: Yes

Response Elements

The following element is returned in a structure named GetQueueAttributesResult.

Attributes

A map of attributes to the respective values.

Type: String to String map

Errors

For information about the errors that are common to all actions, see Common Errors.

InvalidAttributeName

The attribute referred to does not exist.

HTTP Status Code: 400

Examples

The following example Query requests 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=2012-11-05
&SignatureMethod=HmacSHA256
&Expires=2013-10-18T22%3A52%3A43PST
&AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE
&SignatureVersion=2
&Signature=Dqlp3Sd6ljTUA9Uf6SGtEExwUQEXAMPLE

      

Sample Response

        
<GetQueueAttributesResponse>
  <GetQueueAttributesResult>
    <Attribute>
      <Name>ReceiveMessageWaitTimeSeconds</Name>
      <Value>2</Value>
    </Attribute>
    <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 three attribute values for the specified queue.

Sample Request


http://sqs.us-east-1.amazonaws.com/123456789012/testQueue/
?Action=GetQueueAttributes
&Action=GetQueueAttributes
&Version=2012-11-05
&AttributeName.1=VisibilityTimeout
&AttributeName.2=DelaySeconds
&AttributeName.3=ReceiveMessageWaitTimeSeconds
&SignatureMethod=HmacSHA256
&Expires=2013-10-18T22%3A52%3A43PST
&AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE
&SignatureVersion=2
&Signature=Dqlp3Sd6ljTUA9Uf6SGtEExwUQEXAMPLE

      

Sample Response


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