Laravel Horizon Pendings jobs in queue redis are not processed

Viewed 386

I am trying to work with multiple queues in a Laravel 9 environment, with Horizon, Redis as the connection for the queues, and multiple queues.

But not even the main one works for me.

They remain in the queue without being processed.

The processes are seen in the queue correctly, Horizons is active, but they are not processed.

Horizon Queue One job

Command for dispatch a job

use App\Jobs\Api\ModemCallJob;

...

foreach ($command_centers as $command_center) {
   ModemCallJob::dispatch($command_center);
}

ModenCallJob

<?php

namespace App\Jobs\Api;

use App\Models\CommandCenter;
use App\Models\LoggerModem;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;

class ModemCallJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected CommandCenter $command_center;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(CommandCenter $command_center)
    {
        $this->onQueue('redis');
        $this->command_center = $command_center;
    }

    public function handle()
    {
        // Logic
        
        // The logic work fine without queue job

    }
}

Supervisor installed

[program:horizon]
process_name=%(program_name)s
command=php /home/abkrim/Sites/sitelight/artisan horizon
autostart=true
autorestart=true
stopasgroup=true
user=abkrim
redirect_stderr=true
stdout_logfile=/home/abkrim/Sites/sitelight/storage/logs/horizon.log
ps aux|grep horizon
abkrim    101512  0.0  0.0  10728   576 pts/5    S+   20:49   0:00 tail -f storage/logs/horizon.log storage/logs/laravel.log
abkrim    109786  1.0  0.1 148560 65656 ?        S    21:21   0:00 php /home/abkrim/Sites/sitelight/artisan horizon
abkrim    109793  1.0  0.2 148560 65984 ?        S    21:21   0:00 /usr/bin/php8.1 artisan horizon:supervisor nox-ozRr:supervisor-1 redis --workers-name=default --balance=auto --max-processes=10 --min-processes=1 --nice=0 --balance-cooldown=3 --balance-max-shift=1 --parent-id=109786 --backoff=0 --max-time=0 --max-jobs=0 --memory=256 --queue=default --sleep=3 --timeout=60 --tries=1 --rest=0
abkrim    109810  1.4  0.1 148572 65364 ?        S    21:21   0:00 /usr/bin/php8.1 artisan horizon:work redis --name=default --supervisor=nox-ozRr:supervisor-1 --backoff=0 --max-time=0 --max-jobs=0 --memory=256 --queue=default --sleep=3 --timeout=60 --tries=1 --rest=0
abkrim    109811  1.3  0.1 148568 65664 ?        S    21:21   0:00 /usr/bin/php8.1 artisan horizon:work redis --name=default --supervisor=nox-ozRr:supervisor-1 --backoff=0 --max-time=0 --max-jobs=0 --memory=256 --queue=default --sleep=3 --timeout=60 --tries=1 --rest=0
abkrim    109812  1.4  0.1 148568 65424 ?        S    21:21   0:00 /usr/bin/php8.1 artisan horizon:work redis --name=default --supervisor=nox-ozRr:supervisor-1 --backoff=0 --max-time=0 --max-jobs=0 --memory=256 --queue=default --sleep=3 --timeout=60 --tries=1 --rest=0
abkrim    109813  1.4  0.1 148564 65556 ?        S    21:21   0:00 /usr/bin/php8.1 artisan horizon:work redis --name=default --supervisor=nox-ozRr:supervisor-1 --backoff=0 --max-time=0 --max-jobs=0 --memory=256 --queue=default --sleep=3 --timeout=60 --tries=1 --rest=0
abkrim    109914  0.0  0.0  11660  2572 pts/11   S+   21:21   0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox horizon

Queue

'redis' => [
   'driver' => 'redis',
   'connection' => 'default',
   'queue' => env('REDIS_QUEUE', 'default'),
   'retry_after' => env('QUEUE_TIMEOUT', 3600), //3600, //60
   'block_for' => null,
   'after_commit' => false,
],

Horizon

 'defaults' => [
     'supervisor-1' => [
         'connection' => 'redis',
         'queue' => ['default'],
         'balance' => 'auto',
         'maxProcesses' => 1,
         'memory' => 256,
         'tries' => 1,
         'timeout' => 60,
         'nice' => 0,
     ],
 ],

 'environments' => [
     'production' => [
         'supervisor-1' => [
             'maxProcesses' => 15,
             'balanceMaxShift' => 1,
             'balanceCooldown' => 3,
             'retry_after' => env('QUEUE_TIMEOUT', 3600) -  10, //3600, //60
         ],
     ],

     'local' => [
         'supervisor-1' => [
             'maxProcesses' => 10,
             'balanceMaxShift' => 1,
             'balanceCooldown' => 3,
             'retry_after' => env('QUEUE_TIMEOUT', 3600) -  10, //3600, //60
         ],
     ],
 ], 

Any ideas?

0 Answers
Related