I need to trigger some code when new items are added to Drupal's queue system. My question, how to do that? How to capture that event?

Further details

I have created a custom views bulk operation which enqueues items into Drupal's queue system for further processing. Usually, the enqueued jobs would run when Cron runs. I need to execute a function when new items are added to the queue by VBO. I could query the database every minute to check for new items, but I hope it is possible to listen to that insertion event using a rule or a hook.

1 Answer 1


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 the createItem method. Just copy the original one and add your custom functionality.

After that you need to let Drupal know about your new queue class.

The downside is that it would override the class of your queue for every operation on it.

  • I will consider using this approach. I hope there is a more straightforward method for detecting insertion of new items to the queue.
    – W.M.
    Feb 18, 2017 at 12:25

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.