2016-05-16 129 views
1

我在Ubuntu 14.04服务器中使用数据库驱动程序实现了laravel队列。我执行此代码Laravel数据库排队作业尝试

php /path to app/artisan queue:listen --tries=3 --env=local 

它说试试= 3。但是当我看到就业表时,我看到有22次尝试的工作,这怎么可能?它应该尝试3次,然后将其添加到failed_jobs表中。

此外,在作业表中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'); 
} 
} 
+0

你应该显示作业它自我。问题可能在于此。 –

+0

好吧,我把它。谢谢 –

回答

0

当您提供的CLI尝试次数工作,Laravel工人要去申请的尝试限制仅适用于当前在队列中的那些工作(如果您愿意,也可以在您未执行的工作表中)。为了使工作的每一个执行有一个尝试的限制,你应该把公共$尝试属性,在招聘类作为Dispatching Jobs的Laravel文档中所述(对于Laravel 5.4)

public $tries = 3; 
protected $notification; 
protected $reservation; 
protected $info_changed;