如何解决如何以低优先级执行laravel作业?
我们的laravel应用程序中有多个作业。当前,所有作业都立即排队,并且一个接一个地执行。我希望该特定作业以低优先级执行,这意味着在该作业之后是否应该执行其他任何作业。
BulkPdfPrintLabel::withChain([
new MergeLabel($filepath,$manifest_id,$last,$user_id,$user_type)
])->dispatch($consignments,$user_type,$filepath);
解决方法
改为使用此代码:
// 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,$user_type,$filepath);
更新
// This job is sent to the "low" queue.("low" is custom and you can change it)
BulkPdfPrintLabel::withChain([
new MergeLabel($filepath,$user_type)->onQueue("low")
])
->dispatch($consignments,$filepath);
然后运行此命令来为您的默认队列设置高优先级:
php artisan queue:work --queue=high,default
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。