# Class Queue

A queue holds messages. Ideally, a queue is created per work type. For example, if you want to compress files, you would create a queue dedicated to this job. Any application that reads from this queue would only compress files.

  OpenCloud\Common\Base
  OpenCloud\Common\Resource\BaseResource
  OpenCloud\Common\Resource\PersistentResource
  OpenCloud\Queues\Resource\Queue

Namespace: OpenCloud\Queues\Resource
Located at OpenCloud/Queues/Resource/Queue.php

Methods summary
`public mixed` | # `setName( mixed $name )` Set the name (with validation). Set the name (with validation). #### Parameters $name `mixed` $name string #### Returns `mixed` $this #### Throws ``OpenCloud\Queues\Exception\QueueException``
`public string` | # `getName( )` #### Returns `string`
`public mixed` | # `saveMetadata( array $params = array() )` Save this metadata both to the local object and the API. Save this metadata both to the local object and the API. #### Parameters $params `array` $params #### Returns `mixed`
`public` | # `retrieveMetadata( )` Retrieve metadata from the API and set it to the local object. Retrieve metadata from the API and set it to the local object.
`public Guzzle\Http\Message\Response` | # `create( array $params = array() )` Create a new resource Create a new resource #### Parameters $params `array` $params #### Returns `Guzzle\Http\Message\Response` #### Overrides `OpenCloud\Common\Resource\PersistentResource::create()`
`public object` | # `createJson( )` Provides JSON for create request body Provides JSON for create request body #### Returns `object` #### Throws ``RuntimeException`` #### Overrides `OpenCloud\Common\Resource\PersistentResource::createJson()`
`public string` | # `primaryKeyField( )` Returns the primary key field for the object Returns the primary key field for the object #### Returns `string` #### Overrides `OpenCloud\Common\Resource\BaseResource::primaryKeyField()`
`public Guzzle\Http\Message\Response` | # `update( array $params = array() )` Update a resource Update a resource #### Parameters $params `array` $params #### Returns `Guzzle\Http\Message\Response` #### Overrides `OpenCloud\Common\Resource\PersistentResource::update()`
`public object` | # `getStats( )` This operation returns queue statistics including how many messages are in the queue, broken out by status. This operation returns queue statistics including how many messages are in the queue, broken out by status. #### Returns `object`
`public `OpenCloud\Queues\Resource\Message`` | # `getMessage( string|null $id = null )` Gets a message either by a specific ID, or, if no ID is specified, just an empty Message object. Gets a message either by a specific ID, or, if no ID is specified, just an empty Message object. #### Parameters $id `string|null` $id If a string, then the service will retrieve an individual message based on its specific ID. If NULL, then an empty object is returned for further use. #### Returns ``OpenCloud\Queues\Resource\Message``
`public boolean` | # `createMessage( array $params )` Post an individual message. Post an individual message. #### Parameters $params `array` $params #### Returns `boolean`
`public boolean` | # `createMessages( array $messages )` Post multiple messages. Post multiple messages. #### Parameters $messages `array` $messages #### Returns `boolean`
`public Collection` | # `listMessages( array $options = array() )` Lists messages according to certain filter options. Results are ordered by age, oldest message first. All of the parameters are optional. Lists messages according to certain filter options. Results are ordered by age, oldest message first. All of the parameters are optional. #### Parameters $options `array` $options An associative array of filtering parameters: - ids (array) A two-dimensional array of IDs to retrieve. - claim_id (string) The claim ID to which the message is associated. - marker (string) An opaque string that the client can use to request the next batch of messages. If not specified, the API will return all messages at the head of the queue (up to limit). - limit (integer) A number up to 20 (the default, but is configurable) queues to return. If not specified, it defaults to 10. - echo (bool) Determines whether the API returns a client's own messages, as determined by the uuid portion of the User-Agent header. If not specified, echo defaults to FALSE. - include_claimed (bool) Determines whether the API returns claimed messages as well as unclaimed messages. If not specified, defaults to FALSE (i.e. only unclaimed messages are returned). #### Returns `Collection`
`public boolean` | # `deleteMessages( array $ids )` This operation immediately deletes the specified messages, providing a means for bulk deletes. This operation immediately deletes the specified messages, providing a means for bulk deletes. #### Parameters $ids `array` $ids Two-dimensional array of IDs to be deleted #### Returns `boolean`
`public` | # `claimMessages( array $options = array() )` This operation claims a set of messages, up to limit, from oldest to newest, skipping any that are already claimed. If no unclaimed messages are available, FALSE is returned. This operation claims a set of messages, up to limit, from oldest to newest, skipping any that are already claimed. If no unclaimed messages are available, FALSE is returned. You should delete the message when you have finished processing it, before the claim expires, to ensure the message is processed only once. Be aware that you must call the delete() method on the Message object and pass in the Claim ID, rather than relying on the service's bulk delete deleteMessages() method. This is so that the server can return an error if the claim just expired, giving you a chance to roll back your processing of the given message, since another worker will likely claim the message and process it. Just as with a message's age, the age given for the claim is relative to the server's clock, and is useful for determining how quickly messages are getting processed, and whether a given message's claim is about to expire. When a claim expires, it is removed, allowing another client worker to claim the message in the case that the original worker fails to process it. #### Parameters $options `integer` $limit
`public `OpenCloud\Queues\Resource\Claim`` | # `getClaim( integer $id = null )` If an ID is supplied, the API is queried for a persistent object; otherwise an empty object is returned. If an ID is supplied, the API is queried for a persistent object; otherwise an empty object is returned. #### Parameters $id `integer` $id #### Returns ``OpenCloud\Queues\Resource\Claim``

Methods inherited from OpenCloud\Common\Resource\PersistentResource
`checkExtension(), delete(), getAlias(), noCreate(), noDelete(), noUpdate(), refresh(), refreshFromLocationUrl(), updateJson(), waitFor()`

Methods inherited from OpenCloud\Common\Resource\BaseResource
`__construct(), findLink(), getClient(), getMetadata(), getParent(), getService(), getUrl(), jsonCollectionElement(), jsonCollectionName(), jsonName(), parseResponse(), resourceName(), setMetadata(), setParent(), setService()`

Methods inherited from OpenCloud\Common\Base
`__call(), checkJsonError(), generateUuid(), getInstance(), getJsonHeader(), getLogger(), getProperty(), makeResourceIteratorOptions(), populate(), propertyExists(), setLogger(), setProperty(), stripNamespace(), toCamel(), toUnderscores()`

Constants summary
`integer` | `MAX_POST_MESSAGES` | `10` | # Maximum number of messages that can be posted at once. Maximum number of messages that can be posted at once.

Properties summary
`protected array|`OpenCloud\Common\Metadata`` | $metadata | `` | # Miscellaneous, user-defined information about the queue. Miscellaneous, user-defined information about the queue.
`protected static string` | $url_resource | `'queues'` | #
`protected static string` | $json_collection_name | `'queues'` | #
`protected static boolean` | $json_name | `false` | #
`public array` | $createKeys | `array('name')` | #

Properties inherited from OpenCloud\Common\Resource\BaseResource
`$parent, $service`

Properties inherited from OpenCloud\Common\Base
`$aliases`