Laravel Horizon - Multiple queues running from one supervisor
Asked Answered
P

2

6

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,
    ],
Pilose answered 19/12, 2018 at 0:55 Comment(3)
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.Pilose
I think you didn't restart, the code is okCowell
@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.Gayden
S
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']
],

Seedy answered 31/7, 2023 at 14:20 Comment(0)
M
-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
Maryjomaryl answered 19/6, 2019 at 9:16 Comment(2)
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.Gayden
Indeed you should end up with only one supervisor process to run your php artisan horizon, letting horizon managing your workersPalestrina

© 2022 - 2024 — McMap. All rights reserved.