php - Laravel Horizo​​n 中只执行一次作业的设置是什么?

标签 php laravel redis queue laravel-horizon

我对如何只运行一次作业有点困惑,因为当我将参数“tries”设置为 1 并且作业失败时,它会再次执行一次。如果我将 attempts 参数设置为 3,则作业运行 4 次。最后,如果我设置为 0,作业将无限期运行。下面是我在 config/horizo​​n.php 中的设置:

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

下面是我在 config/queue.php 中的设置

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

还有其他问题,什么设置会发送“已尝试多次或运行得太快”?

最佳答案

只需为作业设置一个属性$tries = 1,并在捕获可能的错误时调用$this->fail();

关于php - Laravel Horizo​​n 中只执行一次作业的设置是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47845332/

相关文章:

php - 未定义类常量中的未定义类常量 'MYSQL_ATTR_INIT_COMMAND' (PHP 5.5.3)

mysql - 数据库设计建议

ubuntu - 如何使用 redis.conf 在 ubuntu 上启动多个 redis 服务

ruby-on-rails - Controller 中的查询缓存

ruby-on-rails-4 - Sidekiq worker 未定义的局部变量或方法

javascript - 如何从字符串中删除双引号,单引号以及如何传入ajax调用

PHP:如何以非阻塞方式调用函数?

php - 如何在我的数据库中存储 $_SESSION 值

sql - Laravel 7 时间戳迁移总是返回 0000-00-00 00 :00:00 when importing a csv excel file

laravel - vim : The term 'vim' is not recognized as the name of a cmdlet?