This is end of lifed for Drupal 7, there is a queue in core.

This module is used by modules to queue function calls for execution on cron. The job_queue_add() function is used by modules to add a job to the queue:

/**
 * Add a job to the queue. The function added will be called in the order it
 * was added during cron.
 *
 * @param $function
 *   The function name to call.
 * @param $description
 *   A human-readable description of the queued job.
 * @param $arguments
 *   Optional array of arguments to pass to the function.
 * @param $file
 *   Optional file path which needs to be included for $fucntion.
 * @param $no_duplicate
 *   If TRUE, do not add the job to the queue if one with the same function and
 *   arguments already exists.
 */
function job_queue_add($function, $description, $arguments = array(), $file = '', $no_duplicate = FALSE) {

Example

Normally, to send email from Drupal, the drupal_mail function is used directly to send email. If many emails must be sent at one time, however, this process may cause PHP to time out. Instead, job_queue_add() may be used to queue the job to eventually be executed as cron runs and the job_queue module processes the job queue.

drupal_mail('some-email-id', $to, $subject, $body, $from, $headers);

becomes

job_queue_add('drupal_mail', 'Description of the email process', array('some-email-id', $to, $subject, $body, $from, $headers), '', TRUE);

The first argument is the name of the function we would have otherwise executed, the next is a description to give this job, and the next is the array of arguments that you otherwise would have executed the original function with. The last two arguments are optional; here the TRUE argument to ensure that duplicate emails are not accidentally queued.

Queued jobs are listed in the job queue at http://example.com/admin/reports/job_queue.

As cron is triggered, the queue will be processed and the jobs removed from it. To avoid PHP timeouts, jobs are run until half of the PHP maximum execution time is passed.

Setting Priorities

Modules can allow jobs to be prioritized by function. The hook hook_job_queue_functions() defines functions to prioritize:

function mymodule_job_queue_functions() {
  $functions['drupal_mail'] = array(
    'title' => t('Drupal mail'),
  );

  return $functions;
}

Once defined, the function's priority is configured at http://example.com/admin/settings/job_queue. A priority, from -10 to 10, determines which jobs get priority over others.

Project Information

  • Maintenance status: Unknown
  • Development status: Unknown
  • Module categories: Utility
  • Reported installs: 573 sites currently report using this module. View usage statistics.
  • Downloads: 69,912
  • Last modified: December 2, 2014
  • shieldStable releases are covered by the security advisory policy.
    Look for the shield icon below.

Downloads