laravel queue:work with priority if it exists

Viewed 27

I need my Laravel workers to work with a queue priority, in Laravel documentation it is achieved by using:

php artisan work:queue --queue=jobA,jobB

Running this, all jobs with the queue jobA will dispatched, and then the ones with jobB, but what I need to do is prioritize the jobs with queue jobA, but when there is not more of this jobs remaining, dispatch any of the remaining jobs. I need this in order to make sure that all my workers are being used, because if I have 50 jobs with the queue jobD, and none with the queue jobA, I want that worker to keep working with those remaining while there is none of jobA, something like:

php artisan work:queue --queue=jobA,jobB,[anyOtherJobRemaining]

Where the worker will dispatch all the jobs with queue jobA, then jobB, and then any other available job in the jobs table. What I'm trying to do here is to optimize the way I use the workers, or if there is a better way to achieve this it would be really nice if anyone can point me to the solution. Thank you!

0 Answers
Related