I have implemented the Queue API inside hook_cron, to do certain update operations on a site:

function HOOK_cron() {
  $interval = variable_get('variable_val', 60 * 60 * 24);
  if (time() >= variable_get('cron_next_execution', 0)) {
    variable_set('cron_next_execution', time() + $interval);
    $queue = 'MODULE_queue';
    $queue = DrupalQueue::get($queue);
    $query = db_query('SELECT nid FROM {node} WHERE type=:type', array(':type' => 'profile'))->fetchAll();
    foreach ($query as $node_obj) {
      $node = node_load($node_obj->nid);

where MODULE_queue is name of the queue, who's worker callback does some task on the nodes.

At any moment of time I would like the administrators to be able to run the updates manually using batch. I would like something like this

  • Check if there is anything pending in a queue at the moment Admin chooses to manually update, and execute them in batch.
  • If not just run a manual batch update.

So, I'm stuck at the part where I need to run the queue inside batch. I am not sure if this even is possible. Any pointers would be highly appreciated.

  • 1
    I would prefer to know "how?" over "is it possible?". I can bet it is, even if I don't exactly know how ;)
    – Mołot
    Dec 9, 2013 at 8:38
  • @Mołot There's an answer just below, to answer how :)
    – AjitS
    Dec 11, 2013 at 7:35

1 Answer 1


Check: https://drupal.org/project/queue_ui

Process queue with Batch API

  • I rolled back the edit previously made. There's no point in copying the project page; I have quoted the relevant feature.
    – user49
    Dec 11, 2013 at 2:14
  • Also you'll require this patch to run system queues via Queue UI module - drupal.org/node/700836. Because by default it supports only its own queues.
    – m1r1k
    Dec 11, 2013 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.