Source for file QueueManager.php
Documentation is available at QueueManager.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
* Contains a class for creating, managing, and deleting Amazon Simple Queue
* Copyright 2008 Mike Brittain, silverorange
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* @package Services_Amazon_SQS
* @author Mike Brittain <mike@mikebrittain.com>
* @author Michael Gauthier <mike@silverorange.com>
* @copyright 2008 Mike Brittain, 2008 silverorange
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version CVS: $Id: QueueManager.php 282616 2009-06-23 03:15:29Z gauthierm $
* @link http://pear.php.net/package/Services_Amazon_SQS
* @link http://aws.amazon.com/sqs/
* @link http://s3.amazonaws.com/awsdocs/SQS/20080101/sqs-dg-20080101.pdf
* Amazon SQS client base class.
require_once 'Services/Amazon/SQS.php';
require_once 'Services/Amazon/SQS/Queue.php';
* Class for creating, managing, and deleting Amazon Simple Queue Service
* @package Services_Amazon_SQS
* @author Mike Brittain <mike@mikebrittain.com>
* @author Michael Gauthier <mike@silverorange.com>
* @copyright 2008 Mike Brittain, 2008 silverorange
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link http://pear.php.net/package/Services_Amazon_SQS
* @link http://aws.amazon.com/sqs/
* @link http://s3.amazonaws.com/awsdocs/SQS/20080101/sqs-dg-20080101.pdf
* Gets a list of SQS queues for the current account
* @param string $prefix optional. Only list queues whose name begins with
* the given prefix. If not specified, all queues for
* the account are returned.
* @return array an array of {@link Services_Amazon_SQS_Queue} objects.
* @throws Services_Amazon_SQS_ErrorException if one or more errors are
* @throws Services_Amazon_SQS_HttpException if the HTTP request fails.
$params['Action'] = 'ListQueues';
$params['QueueNamePrefix'] = $prefix;
// get queues from response
$xpath = $response->getXPath ();
$nodes = $xpath->query ('//sqs:QueueUrl');
foreach ($nodes as $node) {
$url = $xpath->evaluate ('string(text())', $node);
* Creates a new queue for the current account
* @param string $name the queue name.
* @param integer $timeout optional. Timeout for message visibility.
* @return Services_Amazon_SQS_Queue the new queue object or false if the
* queue could not be created.
* @throws Services_Amazon_SQS_InvalidQueueException if the queue name is
* not a valid queue name, if the queue was recently deleted or if
* the queue already exists and the visibility timeout value
* differs from the value on the existing queue.
* @throws Services_Amazon_SQS_InvalidTimeoutException if the provided
* <kbd>$timeout</kbd> is not in the valid range.
* @throws Services_Amazon_SQS_ErrorException if one or more errors are
* @throws Services_Amazon_SQS_HttpException if the HTTP request fails.
'name "' . $name . '" is not a valid queue name. Queue names ' .
'must be 1-80 characters long and must consist only of ' .
'alphanumeric characters, dashes or underscores.', 0 , $name);
'specified timeout falls outside the allowable range (0-7200)',
$params['Action'] = 'CreateQueue';
$params['QueueName'] = $name;
$params['DefaultVisibilityTimeout']
= ($timeout !== null ) ? $timeout : 30;
switch ($e->getError ()) {
case 'AWS.SimpleQueueService.QueueDeletedRecently':
'queue "' . $name . '" was deleted recently. Please wait ' .
'60 seconds after deleting a queue before creating a ' .
'queue of the same name.', 0 , $name);
case 'QueueAlreadyExists':
'queue "' . $name . '" already exists. To set a ' .
'different visibility timeout, use the ' .
'Services_Amazon_SQS_Queue::setAttribute() method.',
$xpath = $response->getXPath ();
$queueUrl = $xpath->evaluate ('string(//sqs:QueueUrl/text())');
* All existing messages in the queue will be lost.
* @param Services_Amazon_SQS_Queue|string$queue either a queue object or
* @throws Services_Amazon_SQS_ErrorException if one or more errors are
* @throws Services_Amazon_SQS_HttpException if the HTTP request fails.
$params['Action'] = 'DeleteQueue';
// {{{ isValidQueueName()
* Gets whether or not a queue name is valid for Amazon SQS
* Amazon SQS queue names must conform to the following rules:
* - must be 1 to 80 ASCII characters
* - must contain only alphanumeric characters, dashes (-), and
* @param string $name the queue name to check.
* @return boolean true if the provided queue name is a valid SQS queue
if (preg_match('/^[A-Za-z0-9\-\_]{1,80}$/', $name) === 0 ) {
Documentation generated on Tue, 24 Nov 2009 17:00:04 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.
|