laravel - 为什么我的失败作业在迁移到 Laravel 5.8 后消失了?

标签 laravel laravel-queue laravel-5.8

我有一个带有队列的 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/

相关文章:

Laravel 队列作业不会更新到最新代码

php - 图像未显示在队列中的邮件中 - laravel

javascript - 如何在 Laravel 中使用 adminlte 模式?

php - 2 个键的数组中未定义键 1

php - Laravel:如何允许带有 .php 文件扩展名的路由

mysql - mysql中倒序显示的记录

php - 此路由不支持 GET 方法。支持的方法 : POST. laravel 5.8 Ajax

javascript - 如何在 laravel 中验证 X-editable 请求(服务器端)

php - 如何访问 Laravel 队列中的项目列表?

php - 如何在 Laravel 中修复 GET http ://localhost/storage/users/default. jpg 404(未找到)