Services_Amazon_SQS
[ class tree: Services_Amazon_SQS ] [ index: Services_Amazon_SQS ] [ all elements ]

Class: Services_Amazon_SQS_Queue

Source Location: /Services_Amazon_SQS-0.1.0/Services/Amazon/SQS/Queue.php

Class Overview

Services_Amazon_SQS
   |
   --Services_Amazon_SQS_Queue

A queue in the Amazon SQS


Author(s):

Copyright:

  • 2008 Mike Brittain, 2008 Amazon.com, 2008 silverorange

Methods


Inherited Variables

Inherited Methods

Class: Services_Amazon_SQS

Services_Amazon_SQS::__construct()
Creates a new SQS client
Services_Amazon_SQS::addRequiredParameters()
Adds required authentication and version parameters to an array of parameters
Services_Amazon_SQS::isValidVisibilityTimeout()
Gets whether or not a visibility timeout is valid
Services_Amazon_SQS::sendRequest()
Sends a HTTP request to the queue service using cURL
Services_Amazon_SQS::setRequest()
Sets the HTTP request object to use
Services_Amazon_SQS::signParameters()
Computes the RFC 2104-compliant HMAC signature for request parameters

Class Details

[line 70]
A queue in the Amazon SQS

This class allows sending objects to and receiving objects from a queue on the Amazon SQS. Use the queue URL provided by Amazon through the list or creating methods when instantiating this class.



[ Top ]


Method Detail

__construct (Constructor)   [line 107]

Services_Amazon_SQS_Queue __construct( string $queueUrl, Services_Amazon_SQS_Account|string $accessKey, [string $secretAccessKey = ''], [HTTP_Request2 $request = null])

Creates a PHP SQS queue object

Queue objects are created with the full URL because Amazon reserves the right to change the URL scheme for queues created in the future. Always use the full queue URL.

  • Access: public

Overrides Services_Amazon_SQS::__construct() (Creates a new SQS client)

Parameters:

string   $queueUrl   —  the URL of this queue.
Services_Amazon_SQS_Account|string   $accessKey   —  either a Services_Amazon_SQS_Account object or a string containing the SQS access key for an account.
string   $secretAccessKey   —  if the first parameter is an account object, this parameter is ignored. Otherwise, this parameter is required and is the secret access key for the SQS account.
HTTP_Request2   $request   —  optional. The HTTP request object to use. If not specified, a HTTP request object is created automatically.

[ Top ]

delete   [line 315]

void delete( string $handle)

Deletes a message from this queue
  • Throws: Services_Amazon_SQS_InvalidQueueException if this queue does not exist for the Amazon SQS account.
  • Throws: Services_Amazon_SQS_ErrorException if one or more errors are returned by Amazon.
  • Throws: Services_Amazon_SQS_HttpException if the HTTP request fails.
  • Access: public

Parameters:

string   $handle   —  the receipt handle of the message to delete.

[ Top ]

getAttributes   [line 375]

array getAttributes( [string $name = 'All'])

Gets an associative array of one or more attributes of this queue

Currently, Amazon SQS only allows retrieving the values of the following attributes:

  • <tt>ApproximateNumberOfMessages</tt> - an approximation of the number of messages in this queue.
  • <tt>VisibilityTimeout</tt> - the default time period for which messages are made invisible when retrieved from this queue.
Additionally, the special attribute <tt>All</tt> may be used to retrieve all available attributes.

  • Return: an associative array of available attributes. The attribute name is the array key and the attribute value is the array value.
  • Throws: Services_Amazon_SQS_InvalidAttributeException if an invalid attribute name is requested.
  • Throws: Services_Amazon_SQS_HttpException if the HTTP request fails.
  • Throws: Services_Amazon_SQS_InvalidQueueException if this queue does not exist for the Amazon SQS account.
  • Throws: Services_Amazon_SQS_ErrorException if one or more errors are returned by Amazon.
  • Access: public

Parameters:

string   $name   —  optional. The name of the attribute value to get or <tt>All</tt> to get all available attributes. If not specified, 'All' is used.

[ Top ]

receive   [line 241]

array receive( [integer $count = 1], [integer $timeout = null])

Retrieves one or more messages from this queue

Retrieved messages are made invisible to subsequent requests for the duration of the visibility timeout. To permanently remove a message from this queue, first retrieve the message and them delete it using the Services_Amazon_SQS_Queue::delete() method.

  • Return: an array containing one or more retrieved messages. Each message in the returned array is represented as an associative array with the following keys:
    • <tt>id</tt> - the message id.
    • <tt>body</tt> - the body of the message.
    • <tt>handle</tt> - the receipt handle of the message.
  • Throws: Services_Amazon_SQS_InvalidTimeoutException if the provided <tt>$timeout</tt> is not in the valid range.
  • Throws: Services_Amazon_SQS_HttpException if the HTTP request fails.
  • Throws: Services_Amazon_SQS_InvalidQueueException if this queue does not exist for the Amazon SQS account.
  • Throws: Services_Amazon_SQS_ErrorException if one or more errors are returned by Amazon.
  • Access: public

Parameters:

integer   $count   —  optional. The number of messages to retrieve from the queue. If not specified, one message is retrieved. At most, ten messages may be retrieved.
integer   $timeout   —  optional. The number of seconds that retrieved messages should be hidden from view in the queue. If not specified, the default visibility timeout of this queue is used.

[ Top ]

send   [line 155]

string send( string $message)

Sends a message to this queue
  • Return: the message id of the message.
  • Throws: Services_Amazon_SQS_InvalidMessageException if the message contains characters outside the allowed set or if the message size is greater than 8192 bytes.
  • Throws: Services_Amazon_SQS_ChecksumException if the received checksum from Amazon does not match the calculated checksum of the sent message.
  • Throws: Services_Amazon_SQS_InvalidQueueException if this queue does not exist for the Amazon SQS account.
  • Throws: Services_Amazon_SQS_HttpException if the HTTP request fails.
  • Throws: Services_Amazon_SQS_ErrorException if one or more errors are returned by Amazon.
  • Access: public

Parameters:

string   $message   —  the message to put in this queue.

[ Top ]

setAttribute   [line 441]

void setAttribute( string $name, mixed $value)

Sets an attribute of this queue

Currently, Amazon SQS only allows setting the <tt>VisibilityTimeout</tt> attribute. This attribute sets the default time period for which messages are made invisible when retrieved from this queue.

  • Throws: Services_Amazon_SQS_InvalidAttributeException if an invalid attribute name is set.
  • Throws: Services_Amazon_SQS_HttpException if the HTTP request fails.
  • Throws: Services_Amazon_SQS_InvalidQueueException if this queue does not exist for the Amazon SQS account.
  • Throws: Services_Amazon_SQS_ErrorException if one or more errors are returned by Amazon.
  • Access: public

Parameters:

string   $name   —  the attribute name.
mixed   $value   —  the attribute value.

[ Top ]

__toString   [line 124]

string __toString( )

Gets a string representation of this queue

Specifically, this returns the queue URL of this queue.

  • Return: the URL of this queue.
  • Access: public

[ Top ]


Documentation generated on Thu, 10 Dec 2015 05:51:14 +0000 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.