Laravel 5.5 - Horizon not running second queue automatically
We need to instruct Horizon to start a queue worker that processes the notifications
queue in addition to the default
queue by adding an element to the queue worker configuration in config/horizon.php:
'environments' => [ ... '(environment name)' => [ 'supervisor-1' => [ ... 'queue' => [ 'default', 'notifications' ], ], ],],
The 'queue'
directive declares which queues a Horizon worker watches for jobs. The out-of-box configuration only specifies the default
queue, so the worker will only process jobs pushed to that queue. The above is roughly equivalent to:
php artisan queue:work --queue=default,notifications
...where the first queue in the comma-separated list has the highest priority, and the last queue has the lowest priority. Horizon prioritizes queues by allocating a greater share of the number of processes rather than processing queues in order of priority.
Alternatively, we could add a second worker group to the configuration that processes the second queue:
'(environment name)' => [ 'supervisor-1' => [ ... 'queue' => [ 'default' ], ], 'supervisor-2' => [ ... 'queue' => [ 'notifications' ], ],],
...for which Horizon starts queue worker processes for each each of the two queues that run simultaneously.