Home > other >  Laravel 7 , changing queue connection during runtime not working / horizon
Laravel 7 , changing queue connection during runtime not working / horizon

Time:07-23

This is my config/queue.php

 'redis' => [
        'driver' => 'redis',
        'connection' => 'default',
        'queue' => 'default',
        'retry_after' => 90,
    ],
    'long_run' => [
        'driver' => 'redis',
        'connection' => 'default',
        'queue' => 'default',
        'retry_after' => 3600,
    ],

This is my config/horizon.php

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

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

This is the code I run on my controller, after I do php artisan horizon. It kinda feels like it redirects to the first connection instead, as it exactly times me out after 90 seconds, instead of 3600. I did try php artisan config:cache and restarted horizon, but still the issue persists

 dispatch(new doSomethingJob($path,auth()->user()))->onConnection('long_run');

Changing retry_after on my redis connection will fix the issue, but is not my desired result.

CodePudding user response:

I thought you had to set the driver before calling the dispatch. Can you try :

$job = (new Job(…))->onQueue('driver');
$this->dispatch($job);

CodePudding user response:

Solution: https://stackoverflow.com/a/64040705/15182404 Seems like I forgot to add the supervisor

'supervisor-long-running' => [
            'connection' => 'long_run',
            'queue' => 'default',
            'balance' => 'simple',
            'processes' => 3,
            'tries' => 1,
            'timeout' => 86000 // should be shorter than retry_after out

]

  • Related