dongqie7806 2017-08-22 00:29
浏览 800
已采纳

如何使用Laravel进行异步请求?

In my Laravel 5.4 web app user can request report generation that takes a couple of minutes due to a big amount of data. Because of these he couldn't work with application no more, until report will be generated. To fix this problem I have read about queues in laravel and separated out my report generation code to the job class, but my app still holds until report will be generated. How can I fix that?

To be absolutely clear I will sum up my problem:

  1. User make request for report generation (my app absolutely holds at this moment)
  2. My app receives POST request in routes and calls a function from the controller class.
  3. Controller's function dispatches a job, that should generate report and put it into the client web folder.
  • 写回答

2条回答 默认 最新

  • duanbei6427 2017-08-22 00:57
    关注

    By default, Laravel uses the sync queue driver. This driver executes the queued jobs in the same request as the one they are created in. So this won't make any difference.

    You should take a look at other drivers and use the Laravel queue worker background process to execute jobs to make sure they don't hold the webrequest from completing.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部