我有一个带有队列的 Laravel 项目,每天运行约 1000 个作业。
当作业失败时,在 5.7 中,它被移至 failed_jobs 表,我可以重试它。
迁移到 Laravel 5.8 后,工作机会就消失了。
此代码应将作业标记为失败并将其放入失败作业表中。
/**
* Execute the job.
*/
public function handle()
{
throw new \Exception('WRONG JOB');
}
主管在这种情况下登录:
[2019-04-10 15:07:57][11932] Processing: App\Jobs\ExecuteAction
看起来执行停止了,并且 Queue::failing 事件没有被调用。
这段代码可以工作,但对我来说似乎不正确。
class ExecuteAction implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Execute the job.
*/
public function handle()
{
try {
throw new \Exception('WROOONG');
} catch (\Exception $e) {
if ($this->attempts() < $this->tries) {
$this->release(10);
} else {
$this->fail($e);
}
}
}
}
调用 Queue::failing 事件。
主管日志;
[2019-04-10 15:06:52][11926] Processing: App\Jobs\ExecuteAction
[2019-04-10 15:06:52][11926] Failed: App\Jobs\ExecuteAction
[2019-04-10 15:06:52][11926] Processed: App\Jobs\ExecuteAction
在主管 session 中
command=php /path/to/laravel-project/artisan queue:listen
我做错了什么?
感谢您的帮助。
最佳答案
来自: https://laravel.com/docs/5.8/queues
命令:queue:listen
已从文档中删除,现在使用队列的推荐方法是运行:queue:work
。
参见: https://laravel.com/docs/5.8/queues#running-the-queue-worker
或者您可以使用: Laravel Horizon
关于laravel - 为什么我的失败作业在迁移到 Laravel 5.8 后消失了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55613494/