Laravel-完成工作时的页面很忙

发布于 2025-02-10 03:00:22 字数 449 浏览 3 评论 0原文

我试图将工作发送到队列。

控制器

public function play($id, Request $request)
    {

        
        ProcessResult::dispatch($id);
        
        dd ('done');

作业

public function handle()
    {
        sleep(25) {

代码工作还不错,但是:

  1. “工作”表是空的;
  2. 浏览器中的页面很忙,直到作业未完成为止;
  3. 直到工作未完成之前,DD('DONE')才到达;

驱动程序是Localhost上的数据库。 Laravel 9。

可能是一个错误或对队列逻辑的普遍误解?

Im trying to send a job to the queue.

Controller

public function play($id, Request $request)
    {

        
        ProcessResult::dispatch($id);
        
        dd ('done');

Job

public function handle()
    {
        sleep(25) {

Code works is fine, but:

  1. 'jobs' table is empty;
  2. page in browser is busy until job is not completed;
  3. dd('done') is not arrived until job is not completed;

Driver is database on localhost. Laravel 9.

What could be a mistake or a general misunderstanding of the logic of the queues?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不咬妳我踢妳 2025-02-17 03:00:22

您的问题是您的工作没有排队。您必须设置一些事情才能按照您想要的方式工作。首先,您必须在工作文件中执行以下操作

use Illuminate\Contracts\Queue\ShouldQueue;

class SomeName implements ShouldQueue {
     //....
}

,之后您必须安装 suppprocisor 并设置一些东西。您可以找到有关如何保持Laravel队列在此线程中运行的更多信息

。 >如何保持Laravel队列系统在服务器上运行

Your problem is that your job is not queued. There are a few things that you must set up in order this to work the way you want. First of all, you must do the following in your job file

use Illuminate\Contracts\Queue\ShouldQueue;

class SomeName implements ShouldQueue {
     //....
}

After that you must install supervisor and set up some things. You can find more information for how to keep laravel queue running in this thread

How to keep Laravel Queue system running on server

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文