如何在laravel队列中以编程方式重试作业? [英] How to retry job programmatically in laravel queue?

查看:46
本文介绍了如何在laravel队列中以编程方式重试作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查作业是否未完成?
以及如何告诉作业在作业的句柄函数内重试?
或者我如何才能强制将工作视为失败的工作?

How can I check if a job fails to finish?
And how can I tell the job to retry inside job's handle function?
Or how can I force a job to be considered as a failed job?

推荐答案

我发现代码需要运行失败(或抛出异常)才能被视为作业失败.
我只是在需要的地方放了一个 throw new Exception().
然后 Laravel 将其视为失败的工作.

I figured out that the code needs to fail to run (or throw an exception) to be considered as failed job.
I just put a throw new Exception() where I needed.
Then laravel behaves it as a failed job.

这篇关于如何在laravel队列中以编程方式重试作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆