我已经使用Databse连接在L5中设置了Queue系统,在我运行迁移后,我的数据库中有两个表failed_jobs和jobs。到目前为止一切正常,但是当推送操作失败时,它继续运行并尝试处理操作并且没有删除失败的作业或插入failed_jobs
Queue::push(function($job) use ($id)
{
Account::delete($id);
$job->delete();
});
在上面的例子中,如果不成功,我如何设置尝试次数,然后插入failed_jobs。
我知道这可以使用
完成php artisan queue:listen --tries=3
但是我想要使用闭包,因为我有不同的情况
答案 0 :(得分:0)
答案 1 :(得分:0)
您可以定义作业类本身的最大尝试次数。
如果在作业上指定了最大尝试次数,它将优先于命令行上提供的值。
将此添加到您的工作类别:
INFO - this_user executed the pipeline at 2019-05-29 19:15:47
Started the main logging
Something happened in loop #0
Something happened in loop #1
Something happened in loop #2
Something happened in loop #3
Something happened in loop #4
Loop completed!