class CRM_Queue_Queue

A queue is an object (usually backed by some persistent data store) which stores a list of tasks or messages for use by other processes.

This would ideally be an interface, but it's handy to specify the "function __construct()" and the "$name" handling

Note: This interface closely parallels the DrupalQueueInterface.

Methods

__construct(array $queueSpec)

Create a reference to queue. After constructing the queue, one should usually call createQueue (if it's a new queue) or loadQueue (if it's known to be an existing queue).

string
getName()

Determine the string name of this queue.

createQueue()

Perform any registation or resource-allocation for a new queue

loadQueue()

Perform any loading or pre-fetch for an existing queue.

deleteQueue()

Release any resources claimed by the queue (memory, DB rows, etc)

bool
existsQueue()

Check if the queue exists.

createItem(mixed $data, array $options = array())

Add a new item to the queue.

int
numberOfItems()

Determine number of items remaining in the queue.

object
claimItem(int $lease_time = 3600)

Get the next item.

object
stealItem(int $lease_time = 3600)

Get the next item, even if there's an active lease

deleteItem(object $item)

Remove an item from the queue.

releaseItem(object $item)

Return an item that could not be processed.

Details

at line 58
__construct(array $queueSpec)

Create a reference to queue. After constructing the queue, one should usually call createQueue (if it's a new queue) or loadQueue (if it's known to be an existing queue).

Parameters

array $queueSpec Array with keys: - type: string, required, e.g. "interactive", "immediate", "stomp", "beanstalk" - name: string, required, e.g. "upgrade-tasks" - reset: bool, optional; if a queue is found, then it should be flushed; default to TRUE - (additional keys depending on the queue provider).

at line 67
string getName()

Determine the string name of this queue.

Return Value

string

at line 74
abstract createQueue()

Perform any registation or resource-allocation for a new queue

at line 79
abstract loadQueue()

Perform any loading or pre-fetch for an existing queue.

at line 84
abstract deleteQueue()

Release any resources claimed by the queue (memory, DB rows, etc)

at line 91
abstract bool existsQueue()

Check if the queue exists.

Return Value

bool

at line 102
abstract createItem(mixed $data, array $options = array())

Add a new item to the queue.

Parameters

mixed $data Serializable PHP object or array.
array $options Queue-dependent options; for example, if this is a priority-queue, then $options might specify the item's priority.

at line 109
abstract int numberOfItems()

Determine number of items remaining in the queue.

Return Value

int

at line 120
abstract object claimItem(int $lease_time = 3600)

Get the next item.

Parameters

int $lease_time Seconds.

Return Value

object with key 'data' that matches the inputted data

at line 131
abstract object stealItem(int $lease_time = 3600)

Get the next item, even if there's an active lease

Parameters

int $lease_time Seconds.

Return Value

object with key 'data' that matches the inputted data

at line 139
abstract deleteItem(object $item)

Remove an item from the queue.

Parameters

object $item The item returned by claimItem.

at line 147
abstract releaseItem(object $item)

Return an item that could not be processed.

Parameters

object $item The item returned by claimItem.