4

Can anyone help with the correct configuration within horizon.php to get a single supervisor to run multiple queues? I have tried:

'supervisor-1' => [
    'connection' => 'redis',
    'queue' => ['default', 'queue2'],
    'balance' => 'simple',
    'processes' => 10,
    'tries' => 3,
],

as well as:

'supervisor-1' => [
    'connection' => 'redis',
    'queue' => 'default, queue2',
    'balance' => 'simple',
    'processes' => 10,
    'tries' => 3,
],

The second queue shows up correctly in horizon and I can send jobs to them but they just do not get processed.

I am provisioned on forge and have my queues setup using redis with the following queue.php config:

'redis' => [
        'driver' => 'redis',
        'connection' => 'default',
        'queue' => 'default', // Default Queue
        'retry_after' => 90,
        'block_for' => null,
    ],
Adam Lambert
  • 1,311
  • 3
  • 24
  • 45
  • OK... found the issue almost immediately after posting this! The correct syntax is: `'queue' => 'default, queue2',` (no white space between the queues). I'll leave this open - maybe it will be useful for someone else and there is seems to be fairly little documentation on mutli-queue setups around. – Adam Lambert Dec 19 '18 at 01:01
  • I think you didn't restart, the code is ok – CodeGuru May 20 '20 at 07:56
  • @AdamLambert if having multiple queues like `'queue' => 'default, queue2',` is ther solution to this question, then you should add it as an answer and mark it as accepted answer. – Christos Lytras Jun 24 '21 at 19:45

2 Answers2

0

In the latest version of Horizon (V5) and Laravel (V10) the array declaration is the expected approach:


'supervisor-1' => [
    'connection' => 'redis',
    'queue' => ['default', 'queue2']
],

FullStackFool
  • 1,071
  • 9
  • 15
-3

in config/horizon.php

'supervisor-1' => [
    'connection' => 'redis',
    'queue' => ['default', 'queue2'],
    'balance' => 'simple',
    'processes' => 10,
    'tries' => 3,
],

in supervisor : --queue=default,queue2

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/App/artisan queue:listen redis --queue=default,queue2 --sleep=3 --tries=3 
autostart=true
autorestart=true
user=root
numprocs=8
redirect_stderr=true
stdout_logfile= /var/www/html/App/storage/logs/worker.log
Saurabh Mistry
  • 12,833
  • 5
  • 50
  • 71
  • 3
    When we install and want to use Horizon, we don't use the `artisan queue:listen` nor `artisan queue:work`, we use `artisan horizon`, ref: [Horizon > Supervisor Configuration](https://laravel.com/docs/8.x/horizon#supervisor-configuration). – Christos Lytras Jun 24 '21 at 19:41
  • Indeed you should end up with only one supervisor process to run your `php artisan horizon`, letting horizon managing your workers – François May 05 '22 at 13:35