class CRM_Queue_Runner

The queue runner is a helper which runs all jobs in a queue.

The queue runner is most useful for one-off queues (such as an upgrade); if the intention is to develop a dedicated, long-running worker thread, then one should consider writing a new queue consumer.

Constants

ERROR_CONTINUE

The failed task should be discarded, and queue processing should continue.

ERROR_ABORT

The failed task should be kept in the queue, and queue processing should abort.

Properties

string $title
CRM_Queue_Queue $queue
$errorMode
$isMinimal
$onEnd
$onEndUrl
$pathPrefix
$qrid
array $buttons
CRM_Queue_TaskContext $taskCtx

Methods

static CRM_Queue_Runner|NULL
instance(string $qrid)

Locate a previously-created instance of the queue-runner.

__construct(array $runnerSpec)

FIXME: parameter validation FIXME: document signature of onEnd callback

array
__sleep()

No description

runAllViaWeb()

Redirect to the web-based queue-runner and evaluate all tasks in a queue.

mixed
runAll()

Immediately run all tasks in a queue (until either reaching the end of the queue or encountering an error)

array
runNext(bool $useSteal = FALSE)

Take the next item from the queue and attempt to run it.

array
skipNext(bool $useSteal = FALSE)

Take the next item from the queue and attempt to run it.

releaseErrorItem(object $item)

Release an item in keeping with the error mode.

array
handleEnd()

No description

array
formatTaskResult(bool $isOK, Exception|NULL $exception = NULL)

Format a result record which describes whether the task completed.

Details

at line 83
static CRM_Queue_Runner|NULL instance(string $qrid)

Locate a previously-created instance of the queue-runner.

Parameters

string $qrid The queue-runner ID.

Return Value

CRM_Queue_Runner|NULL

at line 107
__construct(array $runnerSpec)

FIXME: parameter validation FIXME: document signature of onEnd callback

Parameters

array $runnerSpec Array with keys: - queue: CRM_Queue_Queue - errorMode: int, ERROR_CONTINUE or ERROR_ABORT. - onEnd: mixed, a callback to update the UI after running; should be both callable and serializable. - onEndUrl: string, the URL to which one redirects. - pathPrefix: string, prepended to URLs for the web-runner; default: 'civicrm/queue'.

at line 123
array __sleep()

Return Value

array

at line 141
runAllViaWeb()

Redirect to the web-based queue-runner and evaluate all tasks in a queue.

at line 158
mixed runAll()

Immediately run all tasks in a queue (until either reaching the end of the queue or encountering an error)

If the runner has an onEndUrl, then this function will not return

Return Value

mixed TRUE if all tasks complete normally; otherwise, an array describing the failed task

at line 200
array runNext(bool $useSteal = FALSE)

Take the next item from the queue and attempt to run it.

Individual tasks may also throw exceptions -- caller should watch for exceptions.

Parameters

bool $useSteal Whether to steal active locks.

Return Value

array
  • is_error => bool,
    • is_continue => bool,
    • numberOfItems => int,
    • 'last_task_title' => $,
    • 'exception' => $

at line 252
array skipNext(bool $useSteal = FALSE)

Take the next item from the queue and attempt to run it.

Individual tasks may also throw exceptions -- caller should watch for exceptions.

Parameters

bool $useSteal Whether to steal active locks.

Return Value

array
  • is_error => bool,
    • is_continue => bool,
    • numberOfItems => int)

at line 276
protected releaseErrorItem(object $item)

Release an item in keeping with the error mode.

Parameters

object $item The item previously produced by Queue::claimItem.

at line 293
array handleEnd()

Return Value

array
  • is_error => bool,
    • is_continue => bool,
    • numberOfItems => int,
    • redirect_url => string

at line 324
array formatTaskResult(bool $isOK, Exception|NULL $exception = NULL)

Format a result record which describes whether the task completed.

Parameters

bool $isOK TRUE if the task completed successfully.
Exception|NULL $exception If applicable, an unhandled exception that arose during execution.

Return Value

array (is_error => bool, is_continue => bool, numberOfItems => int)

at line 355
protected CRM_Queue_TaskContext getTaskContext()

Return Value

CRM_Queue_TaskContext