Laravel 5.7 作业队列未异步运行
问题描述
我正在尝试使用 Laravel 5.7 jobs queue 在我的数据库中进行一些插入/更新,我可能做错了什么,因为当调用该作业时,它似乎阻塞了我的应用程序,因此,不异步运行.我的代码结构如下:
I'm trying to use Laravel 5.7 jobs queue to make some insertions/updates in my database and i problably made something wrong because when the job is called its seems to be blocking my application, therefore, not running asynchronously. My code is in the following structure:
.env
queue.php
job_caller.php
job_name.php
Obs.:我正在阅读文档,但我找不到问题所在!
Obs.: I'M READING THE DOCUMENTATION, BUT I CANT FIND WHAT'S GOING WRONG !
推荐答案
您使用的是 QUEUE_CONNECTION=sync
,它基本上具有同步行为.
You are using QUEUE_CONNECTION=sync
which basically has synchronous behavior.
请按以下步骤操作:
运行
php artisan queue:table
,它将自动为jobs
表创建迁移
Run
php artisan queue:table
which will create a migration forjobs
table autimatically
运行 php artisan migrate
,它将通过运行迁移来创建表
Run php artisan migrate
which will create the table by running migration
更改QUEUE_CONNECTION=database
,默认情况下会自动使用jobs
表来管理队列.
Change QUEUE_CONNECTION=database
and as per default, it will automatically take jobs
table to manage the queues.
运行php artisan config:clear
清除应用配置缓存
那应该很好.查看文档以获得更多帮助.
That should be good to go. Check documentation for more help.
这篇关于Laravel 5.7 作业队列未异步运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!