0

我们的 laravel 应用程序中有多个工作。目前,所有作业都立即排队,并一一执行。我希望这个特定的作业以低优先级执行,这意味着如果在该作业之后有任何其他作业应该首先执行。

BulkPdfPrintLabel::withChain([
                    new MergeLabel($filepath, $manifest_id, $last, $user_id, $user_type)
                ])->dispatch($consignments, $last, $manifest_id, $user_id, $user_type, $filepath);
4

1 回答 1

0

请改用此代码:

// This job is sent to the default queue that you selected in config/app file
BulkPdfPrintLabel::withChain([
                    new MergeLabel($filepath, $manifest_id, $last, $user_id, $user_type)])
          ->dispatch($consignments, $last, $manifest_id, $user_id, $user_type, $filepath);

更新

// This job is sent to the "low" queue.("low" is custom and you can change it)
BulkPdfPrintLabel::withChain([
                    new MergeLabel($filepath, $manifest_id, $last, $user_id, $user_type)->onQueue("low")
                ])
        ->dispatch($consignments, $last, $manifest_id, $user_id, $user_type, $filepath);

然后运行此命令为您的默认队列设置高优先级:

php artisan queue:work --queue=high,default

参考laravel 队列

于 2020-10-13T06:15:11.230 回答