Laravel 5.1 failed queued jobs fails on failed() method, prevents queue failure event handler from being called

一笑奈何 提交于 2019-12-03 14:43:23

Try this out from my conversation with Graham at https://github.com/laravel/framework/issues/9799

In the end the most elegant solution I could find to get the the failed() method to trigger on the job class itself was to add to the below to the boot() method of EventServiceProvider.php. Catching the full fail event that is fired and then digging out the command/job and unserializing it to call the failed() method.

Queue::failing(function($connection, $job, $data)
        {
            $command = (unserialize($data['data']['command']));
            $command->failed();
        });

If you start the queue listener like this

nohup php artisan queue:listen > storage/logs/queue.log 2>&1 &

then a queue log file will be created and populated automatically.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!