Service/Amazon/Sqs.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Service
- Subpackage
- Amazon_Sqs
- Version
- $Id: Sqs.php 25024 2012-07-30 15:08:15Z rob $
\Zend_Service_Amazon_Sqs
Class for connecting to the Amazon Simple Queue Service (SQS)
- Parent(s)
- \Zend_Service_Amazon_Abstract < \Zend_Service_Abstract
- See
- \global\http://aws.amazon.com/sqs/
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants
Properties


string $_accessKey =
- Type
- string
- Inherited_from
- \Zend_Service_Amazon_Abstract::$$_accessKey


string $_defaultAccessKey = null
null
Details- Type
- string
- Inherited_from
- \Zend_Service_Amazon_Abstract::$$_defaultAccessKey


string $_defaultSecretKey = null
null
Details- Type
- string
- Inherited_from
- \Zend_Service_Amazon_Abstract::$$_defaultSecretKey


\Zend_Http_Client $_httpClient = null
HTTP Client used to query all web services
Inherited from: \Zend_Service_Abstract::$$_httpClient\Zend_Service_Amazon_Abstract::$$_httpClientnull
Details- Type
- \Zend_Http_Client
- Inherited_from
- \Zend_Service_Abstract::$$_httpClient
- Inherited_from
- \Zend_Service_Amazon_Abstract::$$_httpClient


string $_secretKey =
- Type
- string
- Inherited_from
- \Zend_Service_Amazon_Abstract::$$_secretKey


$_sqsEndpoint = 'queue.amazonaws.com'
HTTP end point for the Amazon SQS service
'queue.amazonaws.com'
Details- Type
- n/a


$_sqsEndpoints = array('us-east-1' => 'sqs.us-east-1.amazonaws.com', 'us-west-1' => 'sqs.us-west-1.amazonaws.com', 'eu-west-1' => 'sqs.eu-west-1.amazonaws.com', 'ap-southeast-1' => 'sqs.ap-southeast-1.amazonaws.com', 'ap-northeast-1' => 'sqs.ap-northeast-1.amazonaws.com')
array('us-east-1' => 'sqs.us-east-1.amazonaws.com', 'us-west-1' => 'sqs.us-west-1.amazonaws.com', 'eu-west-1' => 'sqs.eu-west-1.amazonaws.com', 'ap-southeast-1' => 'sqs.ap-southeast-1.amazonaws.com', 'ap-northeast-1' => 'sqs.ap-northeast-1.amazonaws.com')
Details- Type
- n/a


$_sqsSignatureMethod = 'HmacSHA256'
Signature Encoding Method
'HmacSHA256'
Details- Type
- n/a
Methods


__construct(string $accessKey = null, string $secretKey = null, string $region = null) : void
Constructor
The default region is us-east-1. Use the region to set it to one of the regions that is build-in into ZF. To add a new AWS region use the setEndpoint() method.
Name | Type | Description |
---|---|---|
$accessKey | string | |
$secretKey | string | |
$region | string |


_getAccessKey() : string
Method to fetch the Access Key
Inherited from: \Zend_Service_Amazon_Abstract::_getAccessKey()Type | Description |
---|---|
string |


_getSecretKey() : string
Method to fetch the Secret AWS Key
Inherited from: \Zend_Service_Amazon_Abstract::_getSecretKey()Type | Description |
---|---|
string |


_makeRequest( $queue_url, string $action, array $params = array()) : \SimpleXMLElement
Make a request to Amazon SQS
Name | Type | Description |
---|---|---|
$queue_url | ||
$action | string | SQS action |
$params | array |
Type | Description |
---|---|
\SimpleXMLElement |


_setEndpoint(string $region) : void
Set SQS endpoint
Checks and sets endpoint if region exists in $_sqsEndpoints. If a new SQS region is added by amazon, please use the setEndpoint function to set it.
Name | Type | Description |
---|---|---|
$region | string | region |
Exception | Description |
---|---|
\Zend_Service_Amazon_Sqs_Exception |


_signParameters(string $queue_url, $paramaters) : string
Computes the RFC 2104-compliant HMAC signature for request parameters
This implements the Amazon Web Services signature, as per the following specification:
Sort all request parameters (including SignatureVersion and excluding Signature, the value of which is being created), ignoring case.
Iterate over the sorted list and append the parameter name (in its original case) and then its value. Do not URL-encode the parameter values before constructing this string. Do not use any separator characters when appending strings.
Name | Type | Description |
---|---|---|
$queue_url | string | Queue URL |
$paramaters |
Type | Description |
---|---|
string | the signed data. |


addRequiredParameters(string $queue_url, array $parameters) : array
Adds required authentication and version parameters to an array of parameters
The required parameters are: - AWSAccessKey - SignatureVersion - Timestamp - Version and - Signature
If a required parameter is already set in the $parameters array, it is overwritten.
Name | Type | Description |
---|---|---|
$queue_url | string | Queue URL |
$parameters | array | the array to which to add the required parameters. |
Type | Description |
---|---|
array |


count(string $queue_url) : integer
Return the approximate number of messages in the queue
Name | Type | Description |
---|---|---|
$queue_url | string | Queue URL |
Type | Description |
---|---|
integer |
Exception | Description |
---|---|
\Zend_Service_Amazon_Sqs_Exception |


create(string $queue_name, integer $timeout = null) : string | boolean
Create a new queue
Visibility timeout is how long a message is left in the queue "invisible" to other readers. If the message is acknowleged (deleted) before the timeout, then the message is deleted. However, if the timeout expires then the message will be made available to other queue readers.
Name | Type | Description |
---|---|---|
$queue_name | string | queue name |
$timeout | integer | default visibility timeout |
Type | Description |
---|---|
string | boolean |
Exception | Description |
---|---|
\Zend_Service_Amazon_Sqs_Exception |


delete(string $queue_url) : boolean
Delete a queue and all of it's messages
Returns false if the queue is not found, true if the queue exists
Name | Type | Description |
---|---|---|
$queue_url | string | queue URL |
Type | Description |
---|---|
boolean |
Exception | Description |
---|---|
\Zend_Service_Amazon_Sqs_Exception |


deleteMessage(string $queue_url, string $handle) : boolean
Delete a message from the queue
Returns true if the message is deleted, false if the deletion is unsuccessful.
Name | Type | Description |
---|---|---|
$queue_url | string | Queue URL |
$handle | string | Message handle as returned by SQS |
Type | Description |
---|---|
boolean |
Exception | Description |
---|---|
\Zend_Service_Amazon_Sqs_Exception |


getAttribute(string $queue_url, string $attribute = 'All') : string
Get the attributes for the queue
Name | Type | Description |
---|---|---|
$queue_url | string | Queue URL |
$attribute | string |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\Zend_Service_Amazon_Sqs_Exception |


getEndpoints() : array
Get possible SQS endpoints
Since there is not an SQS webserive to get all possible endpoints, a hardcoded list is available. For the actual region list please check: http://docs.amazonwebservices.com/AWSSimpleQueueService/2009-02-01/APIReference/index.html?QueueServiceWsdlArticle.html
Type | Description |
---|---|
array |


getHttpClient() : \Zend_Http_Client
Gets the HTTP client object.
Inherited from: \Zend_Service_Abstract::getHttpClient()\Zend_Service_Amazon_Abstract::getHttpClient()Type | Description |
---|---|
\Zend_Http_Client |


getQueues() : array
Get an array of all available queues
Type | Description |
---|---|
array |
Exception | Description |
---|---|
\Zend_Service_Amazon_Sqs_Exception |


receive(string $queue_url, integer $max_messages = null, integer $timeout = null) : array
Get messages in the queue
Name | Type | Description |
---|---|---|
$queue_url | string | Queue name |
$max_messages | integer | Maximum number of messages to return |
$timeout | integer | Visibility timeout for these messages |
Type | Description |
---|---|
array |
Exception | Description |
---|---|
\Zend_Service_Amazon_Sqs_Exception |


send(string $queue_url, string $message) : string
Send a message to the queue
Name | Type | Description |
---|---|---|
$queue_url | string | Queue URL |
$message | string | Message to send to the queue |
Type | Description |
---|---|
string | Message ID |
Exception | Description |
---|---|
\Zend_Service_Amazon_Sqs_Exception |


setEndpoint(string $region) : void
Set SQS endpoint
You can set SQS to on of the build-in regions. If the region does not exsist it will be added.
Name | Type | Description |
---|---|---|
$region | string | region |
Exception | Description |
---|---|
\Zend_Service_Amazon_Sqs_Exception |


setHttpClient(\Zend_Http_Client $httpClient) : void
Sets the HTTP client object to use for retrieving the feeds.
Inherited from: \Zend_Service_Abstract::setHttpClient()\Zend_Service_Amazon_Abstract::setHttpClient()If none is set, the default Zend_Http_Client will be used.
Name | Type | Description |
---|---|---|
$httpClient | \Zend_Http_Client |


setKeys( $accessKey, $secretKey) : void
Set the keys to use when accessing SQS.
Inherited from: \Zend_Service_Amazon_Abstract::setKeys()Name | Type | Description |
---|---|---|
$accessKey | ||
$secretKey |