属性 优先于 Laravel 的排队作业
Property precedence of Laravel's queued jobs
我很难弄清楚 laravel 的工作中属性的优先级是什么。
目前,我有一份工作 class 和 tries
和 timeout
属性 描述如下:
class ProcessSmsJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $tries = 3;
public $timeout = 300;
public function __construct()
{
//
}
public function handle()
{
//
}
}
例如,在服务器中,队列工作器具有不同的属性,例如。 tries = 1
和 timeout = 700
。我想知道的是,如果我将此代码推送到服务器,服务器队列工作程序中定义的属性(尝试、超时)是否优先于当前定义的 属性,或者服务器 运行基于此作业的队列 属性 for this job?
另外,一个不相关的问题,如果一个作业有 tries = 3
并且作业在第二次尝试时成功执行,记录不会存储在 failed_jobs table 中吧?那么有没有办法确定作业完成执行需要多少次尝试?
文档指出:
One approach to specifying the maximum number of times a job may be attempted is via the --tries
switch on the Artisan command line. This will apply to all jobs processed by the worker unless the job being processed specifies a more specific number of times it may be attempted
工作class里面的$tries
优先
超时也一样。但是请确保您的 $timeout
永远不会大于 queue.php
配置文件中的 retry_after
设置。
关于您的第二个问题:Laravel 本身会记录尝试作业的次数。所以也许作业本身有一个 属性。核实。否则,您可以尝试自己实现一个计数器。
我很难弄清楚 laravel 的工作中属性的优先级是什么。
目前,我有一份工作 class 和 tries
和 timeout
属性 描述如下:
class ProcessSmsJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $tries = 3;
public $timeout = 300;
public function __construct()
{
//
}
public function handle()
{
//
}
}
例如,在服务器中,队列工作器具有不同的属性,例如。 tries = 1
和 timeout = 700
。我想知道的是,如果我将此代码推送到服务器,服务器队列工作程序中定义的属性(尝试、超时)是否优先于当前定义的 属性,或者服务器 运行基于此作业的队列 属性 for this job?
另外,一个不相关的问题,如果一个作业有 tries = 3
并且作业在第二次尝试时成功执行,记录不会存储在 failed_jobs table 中吧?那么有没有办法确定作业完成执行需要多少次尝试?
文档指出:
One approach to specifying the maximum number of times a job may be attempted is via the
--tries
switch on the Artisan command line. This will apply to all jobs processed by the worker unless the job being processed specifies a more specific number of times it may be attempted
工作class里面的$tries
优先
超时也一样。但是请确保您的 $timeout
永远不会大于 queue.php
配置文件中的 retry_after
设置。
关于您的第二个问题:Laravel 本身会记录尝试作业的次数。所以也许作业本身有一个 属性。核实。否则,您可以尝试自己实现一个计数器。