2017-06-05 70 views
0

我试图在延迟中使用Laravel中的队列。我永远无法延迟工作,所有的工作立即被解雇。延迟排队的作业立即通过数据库驱动程序触发

我在config/queue.php和.env中设置了驱动程序作为“数据库”我还使用php artisan创建了作业表并迁移。 运行php工匠队列:工作或队列:侦听具有相同的效果,作业立即启动。

我在我的数据库,在工作表,字段“available_at”和“created_at”,其实都包含相同的时间戳看到,无视我把代码中的延迟:

$job = (new ParkingMatchJob($this->seller,$this->job_counter+1))->delay(Carbon::now()->addSeconds(20)); 
$this->dispatch($job); 

我也尝试过:

$job = (new ParkingMatchJob($this->seller,$this->job_counter+1))->delay(20); 
$this->dispatch($job); 

无济于事。

我没有看到任何错误laravel.log或php_error.log

我感谢你在前进,如果你能帮助我。

+0

你实现你的类'ParkingMatchJob'的'ShouldQueue'接口? – JiFus

+0

class ParkingMatchJob implements ShouldQueue –

+0

use Dispatchable,InteractsWithQueue,Queueable,SerializesModels; –

回答

0

我认为发货没有正确的顺序。

延迟()之前,它应该是:

ParkingMatchJob::dispatch($this->seller,$this->job_counter+1)->delay(Carbon::now()->addSeconds(20));