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.
----------------------------------------------------------------------------------------------
Can somebody please implend this? Cause this will come in handy on shared servers..

Ps: i dont have a patch, but the code example above is clear enough..

Comments

capellic’s picture

Version: 5.x-1.3 » 6.x-2.x-dev

I think this is an important feature, especially when Invite is used with Contact Importer-- you can easily have 100s of emails being sent.

avpaderno’s picture

Status: Active » Closed (outdated)

I am closing this issue, since it's for a Drupal version no longer supported.