10 months ago

How do I check if a model has a job on the queue?

Posted 10 months ago by gregghoush

For many reasons, my queueing and job processing is a bit more complicated than just tossing jobs on the queue. I require some specific chaining and some jobs depend on other jobs having finished. I could explain it in a few paragraphs, but lets assume for a minute thats true.

I need to be able to ask the question "Does this model have a job in the queue?". I don't care what job (I have 16 total job classes). It just has to exist on the queue currently, in any one of those jobs.

I am using the Redis queue driver with default settings, and Horizon for managing/monitoring.

My hope is to figure out either an existing function call I can use, or write a function that works similar to this:

$hasJob = isModelQueued($myModel);

It would return a simple true/false. True would just mean that a job, any job, exists and has that model.

Please sign in or create an account to participate in this conversation.