Skip to content



Hook to inform background queue processor not to process items.

This hook is called when a background process attempts to claim an item from the queue to process. A hook could alter the status from 'active' to denote that the server is busy & hence no item should be claimed and processed at this time.


hook_civicrm_QueueActive(string &$status, string $queueName, array $queueSpecification) : void


  • @param string $status This will be set to active. It is recommended hooks change it to 'paused' to prevent queue processing (although currently any value other than active is treated as inactive 'paused')
  • @param string $queueName The name of the queue. Equivalent to
  • @param array $queueSpecification Array of information about the queue loaded from civicrm_queue.


From 5.67


  my_extension_civicrm_QueueActive(string &$status): void {
    $threshold = (int) \CRM_Utils_Constant::value('busy_threshold', 500);
    if (!$threshold) {
    $thresholdNumberOfMinutes = (int) \CRM_Utils_Constant::value('busy_threshold_minutes', 5);
    $countOfContributionsInTimeFrame = \CRM_Core_DAO::singleValueQuery(
      '   SELECT COUNT(*) FROM log_civicrm_contribution WHERE log_date > DATE_SUB(NOW(), INTERVAL %1 MINUTE)',
      [1 => [$thresholdNumberOfMinutes, 'Integer']]
    if ($countOfContributionsInTimeFrame > $threshold) {
        "Early return as queue is backed up. $countOfContributionsInTimeFrame contributions in the last $thresholdNumberOfMinutes"
        . " minutes is greater than the threshold of $threshold"
      $status = 'busy';