Amazon Simple Queue Service (http://aws.amazon.com/sqs)
2009.04.29
2006-2009 LifeNexus Digital, Inc., and contributors.
| Simplified BSD License | http://opensource.org/licenses/bsd-license.php |
| Tarzan | http://tarzan-aws.com |
| Amazon SQS | http://aws.amazon.com/sqs |
Container for all Amazon SQS-related methods. Inherits additional methods from TarzanCore.
TarzanCore
require_once('tarzan.class.php');
// Instantiate a new AmazonSQS object using the settings from the config.inc.php file.
$sqs = new AmazonSQS();
// Instantiate a new AmazonSQS object using these specific settings.
$sqs = new AmazonSQS($key, $secret_key);
public function __construct( $key = null, $secret_key = null )
The constructor
public
| key | string (Optional) Your Amazon API Key. If blank, it will look for the AWS_KEY constant. |
| secret_key | string (Optional) Your Amazon API Secret Key. If blank, it will look for the AWS_SECRET_KEY constant. |
boolean false if no valid values are set, otherwise true.
| Example Usage | http://tarzan-aws.com |
public function create_queue( $queue_name, $returnCurlHandle = null )
Creates a new queue to store messages in. You must provide a queue name that is unique within the scope of the queues you own. The queue is assigned a queue URL; you must use this URL when performing actions on the queue. When you create a queue, if a queue with the same name already exists, create_queue() returns the queue URL with an error indicating that the queue already exists.
public
| queue_name | string (Required) The name of the queue to use for this action. The queue name must be unique within the scope of all your queues. |
| returnCurlHandle | boolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests. |
TarzanHTTPResponse object
public function delete_queue( $queue_url, $returnCurlHandle = null )
Deletes the queue specified by the queue URL. This will delete the queue even if it’s not empty.
public
| queue_url | string (Required) The URL of the queue to perform the action on. |
| returnCurlHandle | boolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests. |
TarzanHTTPResponse object
public function list_queues( $queue_name_prefix = null, $returnCurlHandle = null )
Returns a list of your queues. A maximum 1000 queue URLs are returned. If you specify a value for the optional <queue_name_prefix> parameter, only queues with a name beginning with the specified value are returned.
public
| queue_name_prefix | string (Optional) String to use for filtering the list results. Only those queues whose name begins with the specified string are returned. |
| returnCurlHandle | boolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests. |
TarzanHTTPResponse object
public function get_queue_attributes( $queue_url, $returnCurlHandle = null )
Gets one or all attributes of a queue.
public
| queue_url | string (Required) The URL of the queue to perform the action on. |
| returnCurlHandle | boolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests. |
TarzanHTTPResponse object
public function set_queue_attributes( $queue_url, $opt = null )
Sets an attribute of a queue. Currently, you can set only the <VisibilityTimeout> attribute for a queue. See Visibility Timeout for more information.
public
| queue_url | string (Required) The URL of the queue to perform the action on. |
| opt | array (Required) Associative array of parameters which can have the following keys: |
| VisibilityTimeout | integer (Optional) Must be an integer from 0 to 7200 (2 hours). |
| returnCurlHandle | boolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests. |
TarzanHTTPResponse object
public function send_message( $queue_url, $message, $returnCurlHandle = null )
Delivers a message to the specified queue.
public
| queue_url | string (Required) The URL of the queue to perform the action on. |
| message | string (Required) Message size cannot exceed 8 KB. Allowed Unicode characters (according to http://www.w3.org/TR/REC-xml/#charsets): #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]. |
| returnCurlHandle | boolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests. |
TarzanHTTPResponse object
public function receive_message( $queue_url, $opt = null )
Retrieves one or more messages from the specified queue, including the message body and message ID of each message. Messages returned by this action stay in the queue until you delete them. However, once a message is returned to a receive_message() request, it is not returned on subsequent receive_message() requests for the duration of the <VisibilityTimeout>. If you do not specify a <VisibilityTimeout> in the request, the overall visibility timeout for the queue is used for the returned messages. A default visibility timeout of 30 seconds is set when you create the queue. You can also set the visibility timeout for the queue by using set_queue_attributes(). See Visibility Timeout for more information.
public
| queue_url | string (Required) The URL of the queue to perform the action on. |
| opt | array (Required) Associative array of parameters which can have the following keys: |
| VisibilityTimeout | integer (Optional) Must be an integer from 0 to 7200 (2 hours). |
| MaxNumberOfMessages | integer (Optional) Maximum number of messages to return, from 1 to 10. Not necessarily all the messages in the queue are returned. If there are fewer messages in the queue than <MaxNumberOfMessages>, the maximum number of messages returned is the current number of messages in the queue. Defaults to 1 message. |
| returnCurlHandle | boolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests. |
TarzanHTTPResponse object
public function delete_message( $queue_url, $receipt_handle, $returnCurlHandle = null )
Unconditionally removes the specified message from the specified queue. Even if the message is locked by another reader due to the visibility timeout setting, it is still deleted from the queue.
public
| queue_url | string (Required) The URL of the queue to perform the action on. |
| receipt_handle | string (Required) The receipt handle of the message to delete, returned by receive_message(). |
| returnCurlHandle | boolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests. |
TarzanHTTPResponse object
public function get_queue_size( $queue_url )
Retrieves the approximate number of messages in the queue.
public
| queue_url | string (Required) The URL of the queue to perform the action on. |
integer The Approximate number of messages in the queue.
| Related | get_queue_attributes() |
| Example Usage | http://tarzan-aws.com |