Documentation

CRM_Queue_TaskHandler extends AutoService
in package
implements EventSubscriberInterface uses CRM_Queue_BasicHandlerTrait

`CRM_Queue_TaskHandler` a list tasks from a queue. It is designed to supported background tasks which run automatically.

This runner is not appropriate for all queues or workloads, so you might choose or create a different runner. For example, CRM_Queue_Runner is geared toward background task lists.

Tags
service

civi.queue.task_handler

Table of Contents

Interfaces

EventSubscriberInterface

Constants

TYPE_NAME  = 'task'
Symbolic name for the kinds of records that we handle.

Methods

getSubscribedEvents()  : mixed
run()  : string
Run a specific item. Determine its status. Update the others.
runBatch()  : void
Run a batch of items, one-by-one.
getItemDetails()  : array<string|int, mixed>
Get detailed info about the item. This is used for debugging.
getItemTitle()  : string
Get a nice title for the item.
isRetriable()  : bool
runItem()  : void
Do a unit of work with one item from the queue.
validateItem()  : bool
relinquishItems()  : void
If the batch of items encounters an 'abort', then any subsequent items (within the same batch) should be returned to the queue for future work.

Constants

TYPE_NAME

Symbolic name for the kinds of records that we handle.

public mixed TYPE_NAME = 'task'

This matches column 'civicrm_queue.runner' and event 'hook_civicrm_queueRun_{NAME}'.

Methods

getSubscribedEvents()

public static getSubscribedEvents() : mixed

run()

Run a specific item. Determine its status. Update the others.

public final run(CRM_Queue_Queue $queue, mixed $item) : string
Parameters
$queue : CRM_Queue_Queue
$item : mixed
Tags
throws
CRM_Core_Exception
Return values
string

One of the following:

  • 'ok': Task executed normally. Removed from queue.
  • 'retry': Task encountered an error. Will try again later.
  • 'delete': Task encountered an error. Will not try again later. Removed from queue.
  • 'abort': Task encountered an error. Will not try again later. Stopped the queue.

getItemDetails()

Get detailed info about the item. This is used for debugging.

protected getItemDetails(mixed $item) : array<string|int, mixed>
Parameters
$item : mixed
Return values
array<string|int, mixed>

runItem()

Do a unit of work with one item from the queue.

protected runItem(mixed $item, mixed $queue) : void
Parameters
$item : mixed
$queue : mixed

validateItem()

protected validateItem(mixed $item) : bool
Parameters
$item : mixed
Return values
bool

        
On this page

Search results