Documentation

CRM_Queue_Queue_Memory extends CRM_Queue_Queue
in package

A queue implementation which stores items in the CiviCRM SQL database

Table of Contents

Constants

DEFAULT_LEASE_TIME  = 3600

Properties

$items  : array<string|int, mixed>
$nextQueueItemId  : mixed
$releaseTimes  : array<string|int, mixed>
$queueSpec  : array{name: string, type: string, runner: string, batch_limit: int, lease_time: ?int, retry_limit: int, retry_interval: ?int}
$runCounts  : array<string|int, mixed>
Number of times each queue item has been attempted.
$_name  : string

Methods

__construct()  : mixed
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).
claimItem()  : object
Get and remove the next item.
createItem()  : mixed
Add a new item to the queue.
createQueue()  : mixed
Perform any registation or resource-allocation for a new queue
deleteItem()  : mixed
Remove an item from the queue.
deleteQueue()  : mixed
Release any resources claimed by the queue (memory, DB rows, etc)
existsQueue()  : bool
Check if the queue exists.
fetchItem()  : CRM_Queue_DAO_QueueItem|object|null
Get the full data for an item.
getName()  : string
Determine the string name of this queue.
getSpec()  : mixed|null
Get a property from the queueSpec.
getStatistic()  : int|float|null
Get summary information about items in the queue.
getStatus()  : string|null
isActive()  : bool
Determine whether this queue is currently active.
loadQueue()  : mixed
Perform any loading or pre-fetch for an existing queue.
numberOfItems()  : int
Determine number of items remaining in the queue.
releaseItem()  : mixed
Return an item that could not be processed.
setStatus()  : void
Change the status of the queue.
stealItem()  : object
Get the next item.

Constants

DEFAULT_LEASE_TIME

public mixed DEFAULT_LEASE_TIME = 3600

Properties

$items

public array<string|int, mixed> $items

array(queueItemId => queueItemData)

$nextQueueItemId

public mixed $nextQueueItemId = 1

$releaseTimes

public array<string|int, mixed> $releaseTimes

array(queueItemId => releaseTime), expressed in seconds since epoch.

$queueSpec

protected array{name: string, type: string, runner: string, batch_limit: int, lease_time: ?int, retry_limit: int, retry_interval: ?int} $queueSpec
Tags
see
CRM_Queue_Service::create()

$runCounts

Number of times each queue item has been attempted.

protected array<string|int, mixed> $runCounts

array(queueItemId => int $count),

$_name

private string $_name

Methods

__construct()

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).

public __construct(array<string|int, mixed> $queueSpec) : mixed
Parameters
$queueSpec : array<string|int, mixed>

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).

claimItem()

Get and remove the next item.

public claimItem([int|null $leaseTime = NULL ]) : object
Parameters
$leaseTime : int|null = NULL

Hold a lease on the claimed item for $X seconds. If NULL, inherit a queue default ($queueSpec['lease_time']) or system default (DEFAULT_LEASE_TIME).

Return values
object

Includes key 'data' that matches the inputted data.

createItem()

Add a new item to the queue.

public createItem(mixed $data[, array<string|int, mixed> $options = [] ]) : mixed
Parameters
$data : mixed

Serializable PHP object or array.

$options : array<string|int, mixed> = []

Queue-dependent options; for example, if this is a priority-queue, then $options might specify the item's priority. Ex: ['release_time' => strtotime('+3 hours')]

createQueue()

Perform any registation or resource-allocation for a new queue

public createQueue() : mixed

deleteItem()

Remove an item from the queue.

public deleteItem(object $item) : mixed
Parameters
$item : object

The item returned by claimItem.

deleteQueue()

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

public deleteQueue() : mixed

existsQueue()

Check if the queue exists.

public existsQueue() : bool
Return values
bool

fetchItem()

Get the full data for an item.

public fetchItem(int|string $id) : CRM_Queue_DAO_QueueItem|object|null

This is a passive peek - it does not claim/steal/release anything.

Parameters
$id : int|string

The unique ID of the task within the queue.

Return values
CRM_Queue_DAO_QueueItem|object|null

$dao

getName()

Determine the string name of this queue.

public getName() : string
Return values
string

getSpec()

Get a property from the queueSpec.

public getSpec(string $field) : mixed|null
Parameters
$field : string
Return values
mixed|null

getStatistic()

Get summary information about items in the queue.

public getStatistic(string $name) : int|float|null
Parameters
$name : string
Tags
see
CRM_Queue_Queue::getStatistic()
Return values
int|float|null

isActive()

Determine whether this queue is currently active.

public isActive() : bool
Tags
throws
CRM_Core_Exception
Return values
bool

TRUE if runners should continue claiming new tasks from this queue

loadQueue()

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

public loadQueue() : mixed

numberOfItems()

Determine number of items remaining in the queue.

public numberOfItems() : int

Use getStatistic(string $name) instead. The definition of numberOfItems() has become conflicted among different subclasses.

Return values
int

releaseItem()

Return an item that could not be processed.

public releaseItem(CRM_Core_DAO $item) : mixed
Parameters
$item : CRM_Core_DAO

The item returned by claimItem.

setStatus()

Change the status of the queue.

public setStatus(string $status) : void
Parameters
$status : string

Ex: 'active', 'draft', 'aborted'

stealItem()

Get the next item.

public stealItem([int|null $leaseTime = NULL ]) : object
Parameters
$leaseTime : int|null = NULL

Hold a lease on the claimed item for $X seconds. If NULL, inherit a queue default ($queueSpec['lease_time']) or system default (DEFAULT_LEASE_TIME).

Return values
object

With key 'data' that matches the inputted data.


        
On this page

Search results