Zend Framework  1.12
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Zend_Service_Amazon_Sqs Class Reference

Public Member Functions

 __construct ($accessKey=null, $secretKey=null, $region=null)
 Constructor.
 
 setEndpoint ($region)
 Set SQS endpoint.
 
 getEndpoint ()
 Get the SQS endpoint.
 
 getEndpoints ()
 Get possible SQS endpoints.
 
 create ($queue_name, $timeout=null)
 Create a new queue.
 
 delete ($queue_url)
 Delete a queue and all of it's messages.
 
 getQueues ()
 Get an array of all available queues.
 
 count ($queue_url)
 Return the approximate number of messages in the queue.
 
 send ($queue_url, $message)
 Send a message to the queue.
 
 receive ($queue_url, $max_messages=null, $timeout=null)
 Get messages in the queue.
 
 deleteMessage ($queue_url, $handle)
 Delete a message from the queue.
 
 getAttribute ($queue_url, $attribute= 'All')
 Get the attributes for the queue.
 
- Public Member Functions inherited from Zend_Service_Amazon_Abstract
 __construct ($accessKey=null, $secretKey=null)
 Create Amazon client.
 

Public Attributes

const CREATE_TIMEOUT_DEFAULT = 30
 Default timeout for createQueue() function.
 

Protected Member Functions

 _setEndpoint ($region)
 Set SQS endpoint.
 
 addRequiredParameters ($queue_url, array $parameters)
 Adds required authentication and version parameters to an array of parameters.
 
 _signParameters ($queue_url, array $paramaters)
 Computes the RFC 2104-compliant HMAC signature for request parameters.
 
- Protected Member Functions inherited from Zend_Service_Amazon_Abstract
 _getAccessKey ()
 Method to fetch the Access Key.
 
 _getSecretKey ()
 Method to fetch the Secret AWS Key.
 

Protected Attributes

 $_sqsEndpoint = 'queue.amazonaws.com'
 HTTP end point for the Amazon SQS service.
 
 $_sqsApiVersion = '2009-02-01'
 The API version to use.
 
 $_sqsSignatureVersion = '2'
 Signature Version.
 
 $_sqsSignatureMethod = 'HmacSHA256'
 Signature Encoding Method.
 
 $_sqsEndpoints
 
- Protected Attributes inherited from Zend_Service_Amazon_Abstract
 $_secretKey
 
 $_accessKey
 

Additional Inherited Members

- Static Public Member Functions inherited from Zend_Service_Amazon_Abstract
static setKeys ($accessKey, $secretKey)
 Set the keys to use when accessing SQS.
 
- Static Protected Attributes inherited from Zend_Service_Amazon_Abstract
static $_defaultAccessKey = null
 
static $_defaultSecretKey = null
 

Constructor & Destructor Documentation

__construct (   $accessKey = null,
  $secretKey = null,
  $region = null 
)

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
string$accessKey
string$secretKey
string$region

Member Function Documentation

_setEndpoint (   $region)
protected

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
string$regionregion
Exceptions
Zend_Service_Amazon_Sqs_Exception
_signParameters (   $queue_url,
array  $paramaters 
)
protected

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
string$queue_urlQueue URL
array$parametersthe parameters for which to get the signature.
Returns
string the signed data.
addRequiredParameters (   $queue_url,
array  $parameters 
)
protected

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
string$queue_urlQueue URL
array$parametersthe array to which to add the required parameters.
Returns
array
count (   $queue_url)

Return the approximate number of messages in the queue.

Parameters
string$queue_urlQueue URL
Returns
integer
Exceptions
Zend_Service_Amazon_Sqs_Exception
create (   $queue_name,
  $timeout = null 
)

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
string$queue_namequeue name
integer$timeoutdefault visibility timeout
Returns
string|boolean
Exceptions
Zend_Service_Amazon_Sqs_Exception
delete (   $queue_url)

Delete a queue and all of it's messages.

Returns false if the queue is not found, true if the queue exists

Parameters
string$queue_urlqueue URL
Returns
boolean
Exceptions
Zend_Service_Amazon_Sqs_Exception
deleteMessage (   $queue_url,
  $handle 
)

Delete a message from the queue.

Returns true if the message is deleted, false if the deletion is unsuccessful.

Parameters
string$queue_urlQueue URL
string$handleMessage handle as returned by SQS
Returns
boolean
Exceptions
Zend_Service_Amazon_Sqs_Exception
getAttribute (   $queue_url,
  $attribute = 'All' 
)

Get the attributes for the queue.

Parameters
string$queue_urlQueue URL
string$attribute
Returns
string
Exceptions
Zend_Service_Amazon_Sqs_Exception
getEndpoint ( )

Get the SQS endpoint.

Returns
string
getEndpoints ( )

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

Parameters
string$regionregion
Returns
array
getQueues ( )

Get an array of all available queues.

Returns
array
Exceptions
Zend_Service_Amazon_Sqs_Exception
receive (   $queue_url,
  $max_messages = null,
  $timeout = null 
)

Get messages in the queue.

Parameters
string$queue_urlQueue name
integer$max_messagesMaximum number of messages to return
integer$timeoutVisibility timeout for these messages
Returns
array
Exceptions
Zend_Service_Amazon_Sqs_Exception
send (   $queue_url,
  $message 
)

Send a message to the queue.

Parameters
string$queue_urlQueue URL
string$messageMessage to send to the queue
Returns
string Message ID
Exceptions
Zend_Service_Amazon_Sqs_Exception
setEndpoint (   $region)

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
string$regionregion
Exceptions
Zend_Service_Amazon_Sqs_Exception

Member Data Documentation

$_sqsApiVersion = '2009-02-01'
protected

The API version to use.

$_sqsEndpoint = 'queue.amazonaws.com'
protected

HTTP end point for the Amazon SQS service.

$_sqsEndpoints
protected
Initial value:
= 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')
$_sqsSignatureMethod = 'HmacSHA256'
protected

Signature Encoding Method.

$_sqsSignatureVersion = '2'
protected

Signature Version.

const CREATE_TIMEOUT_DEFAULT = 30

Default timeout for createQueue() function.