Skip to content

[13.x] Add queue methods to inspect jobs#59511

Open
jackbayliss wants to merge 2 commits intolaravel:13.xfrom
jackbayliss:13.x-job-methods
Open

[13.x] Add queue methods to inspect jobs#59511
jackbayliss wants to merge 2 commits intolaravel:13.xfrom
jackbayliss:13.x-job-methods

Conversation

@jackbayliss
Copy link
Copy Markdown
Contributor

@jackbayliss jackbayliss commented Apr 2, 2026

In this PR there's 3 new methods which can all be accessed from the queue facade:

Queue::pendingJobs();
Queue::delayedJobs();
Queue::reservedJobs();

( which mirrors the size methods )

Each returns a Collection of InspectedJob. which is as a lightweight class to expose uuid, job name, attempts and createdAt of each payload

Which means we can now do cool stuff like:

Queue::reservedJobs('high-priority-queue')->first()->name;
  // => 'App\Jobs\SendEmail'

Queue::pendingJobs()->countBy('name');
  // => ['App\Jobs\SendEmail' => 1842, 'App\Jobs\ProcessOrder' => 43]

I use database queues and have logic to ensure certain jobs aren't running during deployment in Laravel Cloud and other infra. IE imagine there's a job that shouldn't be interrupted by a deployment, that's the scenario, if it's running the deployment script waits for it to finish.

This currently means reaching for DB::table, manually decoding the payload, and knowing that the job class is stored under displayName.. we can access size via the queue facade, but there's no clean way to get more job details without understanding the internals hence the PR :)

I've added the method to each driver, most just being an empty collection as this only works for the Redis and Database drivers.

No contract changes, no B/C (i dont think), but contracts etc could be tightened in 14.x

This probably needs some love / direction. Happy for you to take over or tell me what to adjust into something more fitting, or throw it into the abyss, but thought I'd give this a idea a try!

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

Thanks for submitting a PR!

Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

queue methods to inspect jobs
squash it to save viewing pain

doc

Update InspectedJob.php

csx2

cs

wip tests and clean up
@jackbayliss jackbayliss marked this pull request as ready for review April 3, 2026 18:48
we pass it in.. so no need to see it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant