Skip to main content
9 votes

Running a queue worker without using cron tasks

Queue is processed by cron through core. You can also use Drush and Drupal Console to run queue items as well. Drush: drush queue:list to get the available queues. drush queue:run to run a single ...
Jaypan's user avatar
  • 18k
7 votes
Accepted

Running a queue worker without using cron tasks

Drupal 8 doesn't use hook_queue_info() but annotates the queue class using the @QueueWorker annotation, as in the following code taken from a Drupal core module. /** * Updates a feed's items. * * @...
avpaderno's user avatar
  • 97.9k
6 votes

How do I clear or delete a queue?

In Drupal 8, via drush you can do it this way: $ drush queue:delete your_queue_name Or: $ drush php >>> \Drupal::service('queue')->get('your_queue_name')->deleteQueue() => null
baikho's user avatar
  • 1,755
6 votes

How to check if an item exists in a Queue?

Add this function: /** * Adding item to queue. * * @param string $queue_id * The name of the queue to work with. * @param array $item_data * Arbitrary data to be associated with the new task ...
qzmenko's user avatar
  • 180
5 votes
Accepted

How to create a QueueWorker and run it without cron

What you probably want is a different kind of queue worker. See https://mglaman.dev/blog/flush-and-run-using-kernelterminate-improve-page-speed-performance A simple example: /src/EventSubscriber/...
4uk4's user avatar
  • 102k
5 votes
Accepted

How can I run the inbuilt Drush 10.x commands as user #1?

You could use the pre-command and post-command hooks to achieve this. By using these hooks you can target a specific drush command such as queue:run. Here is an example implementation: <?php ...
Stefanos Petrakis's user avatar
3 votes
Accepted

How can I delete an item depending on the processing result?

Every item passed to processItem() is automatically deleted once processItem() returns, except in the case processItem() throws an exception. In that case, Drupal will log the exception and leave the ...
avpaderno's user avatar
  • 97.9k
3 votes

When should I "send mail by queue" with the SMTP module?

The previous two answers discuss the pros/cons of queuing email when sending large batches. There are different pros/cons when non-batch emails are sent (e.g. triggered by a user registration event). ...
David-o's user avatar
  • 31
3 votes

How to run a cron queue programmatically?

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')-&...
sanket jain's user avatar
2 votes

Auto add nodes on save to a queue using entityqueue

Try Auto Entityqueue module to Automatically add entities to entityqueues.
Abdulla Abu Zakham's user avatar
2 votes

Drupal queue processing at cron run

I encountered this same issue. I fixed it by setting $queue->numberOfItems() into it's own variable and then using the variable in the foreach. If I didn't do this, I found that the number of items ...
but like's user avatar
2 votes

How to process more than one item from queue in each run?

If you want to do it programmatically instead of cron job, then this could be one of the option - $queue_machine_name = 'custom_logger'; $queue = \Drupal::queue($queue_machine_name); $queue_worker = ...
sanket jain's user avatar
2 votes

How to process single queue item using QueueWorker on cron runs?

Queue workers are meant to be processed in batches, not 1-each-cron-run. If you want to process only a single item every cron run, then use the cron-hook.
Eyal's user avatar
  • 3,286
2 votes

Using Drupal Queue

Your queue worker callback takes a single queue item to process at a time, and you do not invoke it manually because you have setup cron to do it for you. Drupal cron will try to process as many ...
mradcliffe's user avatar
  • 5,936
2 votes

Get cron to process QueueWorker items at a specific time

Copied from \Drupal\Core\Annotation\QueueWorker, the annotation and placd where the @QueueWorker annotation is documented. * Worker plugins are used by some queues for processing the individual ...
Berdir's user avatar
  • 83.5k
2 votes

How to detect insertion of new item(s) into Drupal's queue?

There is another question here with some equal requirement: Insert task to Queue only if unique The idea is to create a custom queue class extending the original one. Your custom class only overrides ...
schlicki's user avatar
  • 709
2 votes
Accepted

How do I create a queue derivative?

With the Help of Niklan I was able to resolve the issue . The reason for $Id is NULL because of missing parent constructor call. $Id value is available once parent constructor is called. Full code ...
miststudent2011's user avatar
2 votes

How to get the base URL of a site in Queue API?

The process running the queue worker will be setting that default host. For example, drush cron You may need to set the public host name with the drush request, via uri or use a drush alias. drush --...
David Thomas's user avatar
  • 21.9k
2 votes
Accepted

getPluginDefinition custom QueueWorker empty after upgrade

Please change your constructor and create() method to match the ContainerFactoryPluginInterface interface for the plugin definition details to be passed to the parent class: public function ...
baikho's user avatar
  • 1,755
1 vote

How can I make a big queue faster (read, multithreaded)?

Queues can be separately executed by numerous job runners with drush queue:run <queue_id>.
mona lisa's user avatar
  • 6,344
1 vote

How can I run the inbuilt Drush 10.x commands as user #1?

In continuation to @rémy's comment here // Switching back not possible It is possible to switch back the user account. As per discussion here drush.services.yml services: my_demo.commands: ...
miststudent2011's user avatar
1 vote
Accepted

How to resave all user accounts on a schedule?

Ultimate Cron Provides a UI where you can schedule all the cron jobs. Example: Job Scheduler Provides an API to schedule jobs. Simple example: // Declare scheduler. function ...
No Sssweat's user avatar
  • 31.6k
1 vote

Create a Term Queue on views

Views Aggregation to count nodes tagged by terms You can use Views Aggregation to count the number of nodes that each tag is assigned to, and use that as the Sort criteria. In the Views of type ...
prkos's user avatar
  • 7,186
1 vote

Test a settings form that displays a queue

A functional test satisfies both requirements. <?php namespace Drupal\Tests\google_analytics_counter\Functional; use Drupal\Component\Utility\SafeMarkup; use Drupal\Tests\BrowserTestBase; /** *...
esod's user avatar
  • 329
1 vote

Exception in worker callback prevents queue item from being removed

I have the same issue. For me putting everyhing inside the worker callback function in a try block solved the issue.
keszthelyi's user avatar
1 vote

How to process single queue item using QueueWorker on cron runs?

As per @Eyal's answer, process it via a cron hook like: /** * Implements hook_cron(). */ function example_cron() { $queue = \Drupal::queue('data_provider_queue'); if ($queue_item = $queue->...
baikho's user avatar
  • 1,755
1 vote
Accepted

Ultimate Cron. Invoke a cron from a cron. Set a cron enabled status to TRUE till its queue gets empty. Then set it to FALSE

Answering my own question. In your .info file first define ultimate_cron as dependencies dependencies[] = ultimate_cron Next, in your .module use hook_cronapi() and define two cron attributes. /** ...
sarathkm's user avatar
  • 558
1 vote

How to check if an item exists in a Queue?

Here you can find a nice D7 solution: https://www.webomelette.com/overriding-queues-drupal-7-or-how-not-create-duplicate-queue-items
VladimirM's user avatar
  • 341
1 vote

When should I "send mail by queue" with the SMTP module?

We also did this to control the rate of email flow. As well our SMTP server is a little slow, and errors sometimes for an unknown reason during the authentication phase, upon which we would need to ...
Cameron's user avatar
  • 270

Only top scored, non community-wiki answers of a minimum length are eligible