Queue Attributes

SQS queues have attributes associated with them that can be queried and updated using API operations, and queues may have both editable and noneditable attributes. Editable attributes are configurable settings you can alter by adjusting the attribute. Noneditable attributes include system-generated information about a queue, such as the number of messages it contains.

In the 2007-05-01 version of the SQS Query API, two queue attributes are available:

VisibilityTimeout

The default visibility timeout for the queue; this value is configurable. It may be set when the queue is created and updated anytime afterwards.

ApproximateNumberOfMessages

The SQS system’s best estimate of the number of messages in the queue, including both visible and invisible messages; this value is generated by the system and can only be retrieved, not edited.

Note

This value can only be approximate due to the distributed nature of SQS.

Retrieve Queue Attributes

The GetQueueAttributes operation detailed in Table 8-10 retrieves a queue’s attribute settings.

Table 8-10. GetQueueAttributes request parameters

Parameter NameValueRequired?
ActionGetQueueAttributesYes
AttributeThe name of the queue attribute to retrieve, or All, in which case all the queue’s attributes are returned; valid values are: All, ApproximateNumberOfMessages, and VisibilityTimeoutYes

Here is an XML document returned by the operation. The document includes an AttributeValue element for each attribute retrieved. The AttributeValue element contains ...

Get Programming Amazon Web Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.