set_queue_attributes ( $queue_url, $attribute, $opt )

Sets the value of one or more queue attributes. Valid attributes that can be set are [VisibilityTimeout, Policy, MaximumMessageSize, MessageRetentionPeriod, ReceiveMessageWaitTimeSeconds].

Access

public

Parameters

Parameter

Type

Required

Description

$queue_url

string

Required

The URL of the SQS queue to take action on.

$attribute

array

Required

A map of attributes to set.

  • x - array - Optional - This represents a simple array index.
    • Name - string - Optional - The name of a queue attribute. [Allowed values: Policy, VisibilityTimeout, MaximumMessageSize, MessageRetentionPeriod, ApproximateNumberOfMessages, ApproximateNumberOfMessagesNotVisible, CreatedTimestamp, LastModifiedTimestamp, QueueArn, ApproximateNumberOfMessagesDelayed, DelaySeconds, ReceiveMessageWaitTimeSeconds]
    • Value - string - Optional - The value of a queue attribute.

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Pass one or more Name-Value pairs to change the queue attributes.

// Change visibility timeout
$sqs = new AmazonSQS();
$response = $sqs->set_queue_attributes('example-queue', array(
	array( // Attribute.0
		'Name' => 'VisibilityTimeout',
		'Value' => 7200
	)
));

// Success?
var_dump($response->isOK());
Result:
bool(true)

Set a policy on the queue.

// Change visibility timeout
$sqs = new AmazonSQS();

$queue_url = 'https://sqs.us-east-1.amazonaws.com/123456789012/my-queue';
$topic_arn = 'arn:aws:sns:us-east-1:123456789012:my-topic';

// Create a new policy to manage resource permissions
$policy = new CFPolicy($sqs, array(
	'Version' => '2008-10-17',
	'Id' => 'my-policy-id',
	'Statement' => array(
		array( // Statement #1
			'Resource' => $sqs->get_queue_arn($queue_url), // Set the queue ARN
			'Effect' => 'Allow',
			'Sid' => 'my-rule',
			'Action' => 'sqs:*',
			'Condition' => array(
				'StringEquals' => array(
					'aws:SourceArn' => $topic_arn
				)
			),
			'Principal' => array(
				'AWS' => '*'
			)
		)
	)
));

$response = $sqs->set_queue_attributes('example-queue', array(
	array( // Attribute #1
		'Name' => 'Policy',
		'Value' => $policy->get_json()
	)
));

// Success?
var_dump($response->isOK());
Result:
bool(true)

Related Methods

Source

Method defined in services/sqs.class.php | Toggle source view (12 lines) | View on GitHub

public function set_queue_attributes($queue_url, $attribute, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['QueueUrl'] = $queue_url;
    
    // Required map (non-list)
    $opt = array_merge($opt, CFComplexType::map(array(
        'Attribute' => (is_array($attribute) ? $attribute : array($attribute))
    )));

    return $this->authenticate('SetQueueAttributes', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback