What are the settings to execute job only once in Laravel Horizon?

739 Views Asked by At

I'm a bit confuse about how to run the job only once, because when I set the parameter "tries" to 1 and the job fails, it execute one more time. If I set the tries parameter to 3, the job runs 4 times. And finally if I set to 0, the jobs run indefinitely. Below my settings in config/horizon.php:

'production' =
    'default' => [
            'connection'   => 'redis',
            'queue'        => [
                'default',
                'notifications',
                'dom'
            ],
            'balance'      => 'auto',
            'maxProcesses' => env('MAX_PROCESSES', 45),
            'timeout'      => 60,
            'tries'        => 1,
        ],
    ],

And below my settings in config/queue.php

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

And other question, what setting dispatch the "has been attempted to many times or run too along"?

1

There are 1 best solutions below

0
On BEST ANSWER

Just set an attribute $tries = 1 to the Job, and on the catch of possible errors, call $this->fail();