Queue listener was not started on a server, some jobs where pushed (using Redis driver).
How could I count (or get all) theses jobs ? I did not found any artisan command to get this information.
Queue listener was not started on a server, some jobs where pushed (using Redis driver).
How could I count (or get all) theses jobs ? I did not found any artisan command to get this information.
If someone still looking for an answer here is the way 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 Redis connection name which is null by default, and The $queue
is the name of the queue / tube which is 'default' by default!
Since Laravel 5.3 you can simply use Queue::size()
(see PR).
You can also use the Redis Facade directly by doing this:
use Redis;
\Redis::lrange('queues:$queueName', 0, -1);
Tested in Laravel 5.6 but should work for all 5.X.
You can install Horizon. Laravel Horizon provides a dashboard for monitoring your queues, and allows you to do more configuration to your queue.
composer require laravel/horizon
php artisan vendor:publish --provider="Laravel\Horizon\HorizonServiceProvider"
You have to set .env
config file and config/horizon.php
file.
Tested with Laravel 5.6
If anybody is still looking approach for the older versions of the Laravel:
$connection = 'queue';
$queueName = 'default';
$totalQueuedLeads = Redis::connection($connection)->zcount('queues:'.$queueName.':delayed' , '-inf', '+inf');
I am an PHP Laravel dev, 3 years, I have just known these command recently, so shame on me. ;(
If you are using redis
driver for your queue, you can count all remaining jobs by name:
use Redis;
$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 see the result immediately, you can use php artisan tinker
and hit Redis::llen('queues:default');
.