create_queue ( $queue_name, $opt )

The CreateQueue action creates a new queue, or returns the URL of an existing one. When you request CreateQueue, you provide a name for the queue. To successfully create a new queue, you must provide a name that is unique within the scope of your own queues.

You may pass one or more attributes in the request. If you do not provide a value for any attribute, the queue will have the default value for that attribute. Permitted attributes are the same that can be set using SetQueueAttributes.

If you provide the name of an existing queue, a new queue isn’t created. If the values of attributes provided with the request match up with those on the existing queue, the queue URL is returned. Otherwise, a QueueNameExists error is returned.

Access

public

Parameters

Parameter

Type

Required

Description

$queue_name

string

Required

The name for the queue to be created.

$opt

array

Optional

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

  • Attribute - array - Optional - A map of attributes with their corresponding values.
    • 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.
  • 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

Create a new queue in the (default) US-East region.

// Create a queue
$sqs = new AmazonSQS();
$response = $sqs->create_queue('example-queue');

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

Create a new queue in the EU-West region.

// Create a queue
$sqs = new AmazonSQS();
$sqs->set_region(AmazonSQS::REGION_EU_W1);
$response = $sqs->create_queue('example-queue');

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

Related Methods

Source

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

public function create_queue($queue_name, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['QueueName'] = $queue_name;
    
    // Optional map (non-list)
    if (isset($opt['Attribute']))
    {
        $opt = array_merge($opt, CFComplexType::map(array(
            'Attribute' => $opt['Attribute']
        )));
        unset($opt['Attribute']);
    }

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

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback