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 license@zend.com so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Service
- Subpackage
- Amazon_Sqs
- Version
- $Id$
\Zend_Service_Amazon_Sqs
Package: Zend_Service\Amazon_SqsClass 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-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants


CREATE_TIMEOUT_DEFAULT
= 30Default timeout for createQueue() function
Properties



$_sqsEndpoint = 'queue.amazonaws.com'HTTP end point for the Amazon SQS service
Default value'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')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



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



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


_setEndpoint(string $region) : voidChecks 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| Name | Type | Description |
|---|
| $region | string | region |
|---|
Throws


_signParameters(string $queue_url, $paramaters) : stringComputes 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| Name | Type | Description |
|---|
| $queue_url | string | Queue URL |
|---|
| $paramaters | | |
|---|
Returns| Type | Description |
|---|
| string | the signed data. |



addRequiredParameters(string $queue_url, array $parameters) : arrayAdds 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| Name | Type | Description |
|---|
| $queue_url | string | Queue URL |
|---|
| $parameters | array | the array to which to add the required
parameters. |
|---|
Returns


count(string $queue_url) : integerReturn the approximate number of messages in the queue
Parameters| Name | Type | Description |
|---|
| $queue_url | string | Queue URL |
|---|
ReturnsThrows 


create(string $queue_name, integer $timeout = null) : string | booleanVisibility 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| Name | Type | Description |
|---|
| $queue_name | string | queue name |
|---|
| $timeout | integer | default visibility timeout |
|---|
Returns| Type | Description |
|---|
| string | boolean | |
Throws


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


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


getAttribute(string $queue_url, string $attribute = 'All') : stringGet the attributes for the queue
Parameters| Name | Type | Description |
|---|
| $queue_url | string | Queue URL |
|---|
| $attribute | string | |
|---|
ReturnsThrows 


getEndpoints() : arrayGet 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


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


send(string $queue_url, string $message) : stringSend a message to the queue
Parameters| Name | Type | Description |
|---|
| $queue_url | string | Queue URL |
|---|
| $message | string | Message to send to the queue |
|---|
Returns| Type | Description |
|---|
| string | Message ID |
Throws 


setEndpoint(string $region) : voidYou can set SQS to on of the build-in regions. If the region does not exsist it will be added.
Parameters| Name | Type | Description |
|---|
| $region | string | region |
|---|
Throws