1

Is it possible in code to search for a job/list out all jobs?

I have built a plugin that scans an external API and I want to scan on an interval as well as allow the user to fire off a manual scan. I have found on quicker intervals that the queue can get overwhelmed with jobs quicker than it is able to complete them eventually taking the site down as a whole.

Is there any way to query the queue list for current jobs? either search by name or just get the full list so I can loop through them?

also is it possible to release specific jobs or all jobs from code?

Thanks for any help given

1

Yes, you can access the queue component using \Craft::$app->getQueue(). Keep in mind that this may return null or a non-compatible component depending on configuration, so make sure to check if the queue component is an instance of the craft\queue\QueueInterface.

The default queue component (craft\queue\Queue) has all the methods you need to build your interface:

A good place to discover how Craft uses these core features are the CMS controllers. In this case, craft\controllers\QueueController contains all the endpoints / actions used by the Queue Manager utility and will show you how Craft uses the service methods to build the interface.

I have found on quicker intervals that the queue can get overwhelmed with jobs quicker than it is able to complete them eventually taking the site down as a whole.

This is a bit troubling because the queue should never be able to take down the site. Make sure you're service supervisor gives the queue runner a low priority so it doesn't interfere with site requests. See the article Robost queue job handling in Craft for more information.

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.