Service/Amazon/Sqs.php

Show: PublicProtectedPrivateinherited
Table of Contents
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 license@zend.com 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

Package: Zend\Service\Amazon\Sqs
Class for connecting to the Amazon Simple Queue Service (SQS)
Parent(s)
\Zend_Service_Amazon_Abstract < \Zend_Service_Abstract
See
Amazon Simple Queue Service  
Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

>VConstant  CREATE_TIMEOUT_DEFAULT = 30
Default timeout for createQueue() function

Properties

>VPropertyprotectedstring $_accessKey
inherited

Amazon Access Key

Inherited from: \Zend_Service_Amazon_Abstract::$$_accessKey
Details
Type
string
Inherited_from
\Zend_Service_Amazon_Abstract::$$_accessKey  
>VPropertyprotectedstring $_defaultAccessKey = null
staticinherited

Amazon Access Key

Inherited from: \Zend_Service_Amazon_Abstract::$$_defaultAccessKey
Default valuenullDetails
Type
string
Inherited_from
\Zend_Service_Amazon_Abstract::$$_defaultAccessKey  
>VPropertyprotectedstring $_defaultSecretKey = null
staticinherited

Amazon Secret Key

Inherited from: \Zend_Service_Amazon_Abstract::$$_defaultSecretKey
Default valuenullDetails
Type
string
Inherited_from
\Zend_Service_Amazon_Abstract::$$_defaultSecretKey  
>VPropertyprotected\Zend_Http_Client $_httpClient = null
staticinherited
HTTP Client used to query all web services
Inherited from: \Zend_Service_Abstract::$$_httpClient\Zend_Service_Amazon_Abstract::$$_httpClient
>VPropertyprotectedstring $_secretKey
inherited

Amazon Secret Key

Inherited from: \Zend_Service_Amazon_Abstract::$$_secretKey
Details
Type
string
Inherited_from
\Zend_Service_Amazon_Abstract::$$_secretKey  
>VPropertyprotected$_sqsApiVersion = '2009-02-01'
The API version to use
Default value'2009-02-01'Details
Type
n/a
>VPropertyprotected$_sqsEndpoint = 'queue.amazonaws.com'
HTTP end point for the Amazon SQS service
Default value'queue.amazonaws.com'Details
Type
n/a
>VPropertyprotected$_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')
Default valuearray('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
>VPropertyprotected$_sqsSignatureMethod = 'HmacSHA256'
Signature Encoding Method
Default value'HmacSHA256'Details
Type
n/a
>VPropertyprotected$_sqsSignatureVersion = '2'
Signature Version
Default value'2'Details
Type
n/a

Methods

methodpublic__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.

Parameters
NameTypeDescription
$accessKeystring
$secretKeystring
$regionstring
methodprotected_getAccessKey() : string
inherited

Method to fetch the Access Key

Inherited from: \Zend_Service_Amazon_Abstract::_getAccessKey()
Returns
TypeDescription
string
methodprotected_getSecretKey() : string
inherited

Method to fetch the Secret AWS Key

Inherited from: \Zend_Service_Amazon_Abstract::_getSecretKey()
Returns
TypeDescription
string
methodprivate_makeRequest( $queue_url, string $action, array $params = array()) : \SimpleXMLElement

Make a request to Amazon SQS

Parameters
NameTypeDescription
$queue_url
$actionstring

SQS action

$paramsarray
Returns
TypeDescription
\SimpleXMLElement
methodprotected_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.

Parameters
NameTypeDescription
$regionstring

region

Throws
ExceptionDescription
\Zend_Service_Amazon_Sqs_Exception
methodprotected_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:

  1. Sort all request parameters (including SignatureVersion and excluding Signature, the value of which is being created), ignoring case.

  2. 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.

Parameters
NameTypeDescription
$queue_urlstring

Queue URL

$paramaters
Returns
TypeDescription
stringthe signed data.
methodprotectedaddRequiredParameters(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.

Parameters
NameTypeDescription
$queue_urlstring

Queue URL

$parametersarray

the array to which to add the required parameters.

Returns
TypeDescription
array
methodpubliccount(string $queue_url) : integer

Return the approximate number of messages in the queue

Parameters
NameTypeDescription
$queue_urlstring

Queue URL

Returns
TypeDescription
integer
Throws
ExceptionDescription
\Zend_Service_Amazon_Sqs_Exception
methodpubliccreate(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.

Parameters
NameTypeDescription
$queue_namestring

queue name

$timeoutinteger

default visibility timeout

Returns
TypeDescription
string | boolean
Throws
ExceptionDescription
\Zend_Service_Amazon_Sqs_Exception
methodpublicdelete(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

Parameters
NameTypeDescription
$queue_urlstring

queue URL

Returns
TypeDescription
boolean
Throws
ExceptionDescription
\Zend_Service_Amazon_Sqs_Exception
methodpublicdeleteMessage(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.

Parameters
NameTypeDescription
$queue_urlstring

Queue URL

$handlestring

Message handle as returned by SQS

Returns
TypeDescription
boolean
Throws
ExceptionDescription
\Zend_Service_Amazon_Sqs_Exception
methodpublicgetAttribute(string $queue_url, string $attribute = 'All') : string

Get the attributes for the queue

Parameters
NameTypeDescription
$queue_urlstring

Queue URL

$attributestring
Returns
TypeDescription
string
Throws
ExceptionDescription
\Zend_Service_Amazon_Sqs_Exception
methodpublicgetEndpoint() : string

Get the SQS endpoint

Returns
TypeDescription
string
methodpublicgetEndpoints() : 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

Returns
TypeDescription
array
methodpublicgetHttpClient() : \Zend_Http_Client
staticfinalinherited

Gets the HTTP client object.

Inherited from: \Zend_Service_Abstract::getHttpClient()\Zend_Service_Amazon_Abstract::getHttpClient()
Returns
TypeDescription
\Zend_Http_Client
methodpublicgetQueues() : array

Get an array of all available queues

Returns
TypeDescription
array
Throws
ExceptionDescription
\Zend_Service_Amazon_Sqs_Exception
methodpublicreceive(string $queue_url, integer $max_messages = null, integer $timeout = null) : array

Get messages in the queue

Parameters
NameTypeDescription
$queue_urlstring

Queue name

$max_messagesinteger

Maximum number of messages to return

$timeoutinteger

Visibility timeout for these messages

Returns
TypeDescription
array
Throws
ExceptionDescription
\Zend_Service_Amazon_Sqs_Exception
methodpublicsend(string $queue_url, string $message) : string

Send a message to the queue

Parameters
NameTypeDescription
$queue_urlstring

Queue URL

$messagestring

Message to send to the queue

Returns
TypeDescription
stringMessage ID
Throws
ExceptionDescription
\Zend_Service_Amazon_Sqs_Exception
methodpublicsetEndpoint(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.

Parameters
NameTypeDescription
$regionstring

region

Throws
ExceptionDescription
\Zend_Service_Amazon_Sqs_Exception
methodpublicsetHttpClient(\Zend_Http_Client $httpClient) : void
staticfinalinherited

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.

Parameters
NameTypeDescription
$httpClient\Zend_Http_Client
methodpublicsetKeys( $accessKey,  $secretKey) : void
staticinherited

Set the keys to use when accessing SQS.

Inherited from: \Zend_Service_Amazon_Abstract::setKeys()
Parameters
NameTypeDescription
$accessKey
$secretKey
Documentation was generated by phpDocumentor 2.0.0a12.