4

I have created a cron queue like given below.

function mymodule_cron_queue_info() {
  $queues['aggregator_feeds'] = array(
    'worker callback' => 'aggregator_refresh',
    'time' => 60,
  );
  return $queues;
}

My cron runs when calling drush cron. I need to run the queue 'aggregator_feeds' individually without invoking any other cron queues. Drupal admin panel -> config -> cron : runs all queues as per schedule. drush cron command too runs all queue. How do I run a single queue programmatically?

Also I need to know how to run all the queues programmatically?

1 Answer 1

3

For one of my project, this worked for me :-

$queue_machine_name = 'sync_product_list';
$queue = \Drupal::queue($queue_machine_name); 
$queue_worker = \Drupal::service('plugin.manager.queue_worker')->createInstance($queue_machine_name);
$item_id = '123';
$queue_worker->processItem($item_id);  


Your Answer

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

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