Php Laravel 5.2队列作业不断重试

Php Laravel 5.2队列作业不断重试,php,laravel,redis,laravel-5.2,Php,Laravel,Redis,Laravel 5.2,问题是,当我运行php-artisan-queue:work--daemon或php-artisan-queue:work--daemon--trys=1 尝试选项似乎不起作用。在我的redis队列中,我不断看到它试图做出类似的尝试。它应该只尝试一次,如果作业失败,只需忽略该作业并继续 class ProcessComment extends Job implements ShouldQueue { use InteractsWithQueue; /** * @var

问题是,当我运行
php-artisan-queue:work--daemon
php-artisan-queue:work--daemon--trys=1

尝试
选项似乎不起作用。在我的redis队列中,我不断看到它试图做出类似的尝试。它应该只尝试一次,如果作业失败,只需忽略该作业并继续

class ProcessComment extends Job implements ShouldQueue
{
    use InteractsWithQueue;

    /**
     * @var int
     */
    public $tries = 1;


    public function handle(Somedepency $someDependency) {
         // method body....
         // tries to connect to a database
         // deliberately provide the wrong database url so that the job .  
         // will throw exception and hence faild
    }
等等

这是我的configs/queue.php

"EXEC"
1522044746.165780 [0 172.20.0.5:48992] "WATCH" "queues:comments:reserved"
1522044746.166110 [0 172.20.0.5:48992] "ZRANGEBYSCORE" "queues:comments:reserved" "-inf" "1522044746"
1522044746.166718 [0 172.20.0.5:48992] "UNWATCH"
1522044746.167436 [0 172.20.0.5:48992] "LPOP" "queues:comments"
1522044746.168051 [0 172.20.0.5:48992] "ZADD" "queues:comments:reserved" "1522044806" {"some serialized data here ... "attempts: 4"}
我试着用谷歌搜索,但没能找到满意的答案


谢谢

您所需要做的就是添加一个public$try属性,然后该编号将失败

'default' => env('QUEUE_DRIVER', 'redis'),

    'connections' => [

        'redis' => [
            'driver' => 'redis',
            'connection' => 'default',
            'queue' => 'comments'
        ],
    ],

日志中没有任何内容
?日志中说明了无法连接到数据库的异常情况,并且随着作业一次又一次地运行,此日志不断增加。因此,您有您的答案您的意思是什么?这就是我想要的行为。我故意尝试连接到错误的数据库,以便抛出异常。我想要的是,当抛出异常时,它意味着作业失败。我想让
$尝试
按预期工作。它不应该无限次地重试。
/**
 * The number of times the job may be attempted.
 *
 * @var int
 */
public $tries = 5;