Laravel 作业在没有启动队列的情况下实时执行

Laravel job executing real time without queue being started

运行 在 Laravel 5.8 我正在创建大量作业,我认为一旦队列启动就应该执行这些作业。 我的问题是,当我什至还没有启动队列时,作业就在那里执行了。

它们甚至没有被插入到迁移创建的 jobs table 中。

以下是我认为相关的设置和代码段。如果需要更多信息,请告诉我。

全新安装:

php artisan queue:table
php artisan migrate

.env 文件

QUEUE_CONNECTION=database

创建了排队任务

class FulfillmentTask implements ShouldQueue{
//code here
}

控制器

use App\Jobs\FulfillmentTask;

//rest of the class here

public function somefunction(Request $request){
//some code here
//read csv file
foreach ($fileContents as $row){
            FulfillmentTask::dispatch($orderId, $client, $request->sendEmail)->onQueue('database');
        }
}

问题是执行 FulfillmentTask 时没有在终端中给出 queue:work 命令。

知道为什么会这样吗?

"database"是队列连接。请将您的工作分配给该连接。

FulfillmentTask::dispatch($orderId, $client, $request->sendEmail)->onConnection('database');

这似乎是默认连接,因此您只需分派作业即可。

FulfillmentTask::dispatch($orderId, $client, $request->sendEmail);