How to get all pending jobs in laravel queue on redis?

The queue listener did not start on the server, some jobs that were clicked (using the Redis driver).

How can I read (or get all) theses? I did not find the artisan command to get this information.

+21
source share
6 answers

If someone is still looking for an answer, this is how I do it:

$connection = null; $default = 'default'; //For the delayed jobs var_dump( \Queue::getRedis()->connection($connection)->zrange('queues:'.$default.':delayed' ,0, -1) ); //For the reserved jobs var_dump( \Queue::getRedis()->connection($connection)->zrange('queues:'.$default.':reserved' ,0, -1) ); 

$connection - is the name of Redis connections, which defaults to null, and $queue - queue name / tube, which by default is the default!

+17
source

Starting with Laravel 5.3 you can just use Queue::size() (see PR ).

+9
source

You can also use Redis Facade by following these steps:

 use Redis; \Redis::lrange('queues:$queueName', 0, -1); 

Tested in Laravel 5.6, but should work for all 5.X.

+7
source

I am a PHP developer Laravel, 3 years old, I recently knew these commands, so shame on me .; (

If you use the redis driver for your queue, you can count all the remaining jobs by name:

 use Redis; // List all keys with status (awaiting, reserved, delayed) Redis::keys('*'); // Count by name $queueName = 'default'; echo Redis::llen('queues:' . $queueName); // To count by status: echo Redis::zcount('queues:' . $queueName . ':delayed', '-inf', '+inf'); echo Redis::zcount('queues:' . $queueName . ':reserved', '-inf', '+inf'); 

To immediately see the result, you can use php artisan tinker and click Redis::llen('queues:default'); .

+4
source

You can install Horizon. Laravel Horizon provides a dashboard to monitor your queues and allows you to do more configuration on your queue.

 composer require laravel/horizon php artisan vendor:publish --provider="Laravel\Horizon\HorizonServiceProvider" 

You must install the .env configuration file and the config/horizon.php .

Tested with Laravel 5.6

+2
source

If someone is still looking for an approach to older versions of Laravel:

 $connection = 'queue'; $queueName = 'default'; $totalQueuedLeads = Redis::connection($connection)->zcount('queues:'.$queueName.':delayed' , '-inf', '+inf'); 
0
source

All Articles