我在Ubuntu 14.04服务器上用数据库驱动程序实现了一个laravel队列。我执行这个代码
php /path to app/artisan queue:listen --tries=3 --env=local
上面写着trys=3。但当我看到工作表时,我看到了22次尝试的工作,这怎么可能呢?它应该尝试3次,然后将其添加到failedjobs表中。
此外,reserved_at在作业表中的含义是什么?。
谢谢
这是一项工作,顺便说一句,它完美地工作
<?php
namespace App'Jobs;
use App'Jobs'Job;
use App'Notifiers'Im_Notification;
use App'Notifiers'Notification;
use App'Notifiers'Mail_Notification;
use App'Reservation;
use Illuminate'Queue'SerializesModels;
use Illuminate'Queue'InteractsWithQueue;
use Illuminate'Contracts'Queue'ShouldQueue;
class NotifyPlaceReservationStatus extends Job implements ShouldQueue
{
use InteractsWithQueue, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
protected $notification;
protected $reservation;
protected $info_changed;
public function __construct(Notification $notification,Reservation $reservation)
{
$this->reservation = $reservation;
$this->notification = $notification;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$this->notification->notifyPlaceReservationStatus($this->reservation);
}
public function failed()
{
error_log('Job failed');
}
}
当您在CLI中提供尝试次数时,Laravel worker将仅对队列中当前的作业(如果您愿意,也可以在未执行的作业表中)应用尝试次数限制。为了使作业的每次执行都有一个尝试限制,您应该在作业类中放入一个公共$trys属性,如调度作业的Laravel文档中所述(对于Laravel 5.4)
public $tries = 3;
protected $notification;
protected $reservation;
protected $info_changed;