2

How can I use Drush to pass data into a Drupal Queue?

function hook_cron_queue_info() {
  $queues['my_queue_name'] = array(
    'worker callback' => '_my_queue_callback', // This is the callback function for each queue item.
    'time' => 25, // This is the max run time per cron run in seconds.
  );
  return $queues;
}

function module_name_load_queue($item) {
  $queue = DrupalQueue::get('my_queue_name');
  $queue->createItem(json_encode($item));
}

My ultimate goal is to pre-process data using a few bash scripts and then pass the end result to module_name_load_queue($item); using Drush.

Is this possible? If so, how do I go about this?

0

Yes We can use drush queue run to initiate a queue

Example :

#!/bin/sh
SLEEP=${2} #Make the sleep time as configurable
while true
do
   drush5 --uri=${1} queue-run <Your QUEUE NAME> #${1} Domain URI
   sleep ${SLEEP}
done
  • I'm looking to load (fill) a queue using drush rather than start a queue. Thank you though as this will be useful in the next step. – Citricguy Mar 10 '14 at 23:13
0

The most common practice is to create a custom cron job that populates the queue. Failing that you could use drush ev "my_callback()" to accomplish this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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