laravel excel作业卡住,无法运行

a2mppw5e  于 2022-11-18  发布在  其他
关注(0)|答案(1)|浏览(107)

我正在使用laravel excel包导出一个队列查询。在我的控制台上,当我运行php artisan horizon时,我看到如下的作业:

php artisan horizon
Horizon started successfully.
[2022-02-14 18:09:25][3733] Processing: Maatwebsite\Excel\Jobs\QueueExport
[2022-02-14 18:09:26][3733] Processed:  Maatwebsite\Excel\Jobs\QueueExport

没有更多。它只是冻结在这里,不采取任何其他行动,直到我的下一个请求,然后2到5个作业运行,并再次冻结。任何人有任何想法,我怎么能跟踪日志或修复这个?我的Excel代码是一个出口,如下图:

public function query()
    {
        \Log::critical('Query');
        return Order::query()
            ->when($this->request['from'], function ($query)
                return $query->whereBetween('created_at', [$this->request['from'], $this->request['to']]);
            })
;
    }
public function map($row): array
    {
   return [
            $row['id']
]
}
   public function failed(Throwable $exception): void
    {
        Log::critical('Failed Export '.$exception->getMessage());
    }
nimxete2

nimxete21#

如果您使用自定义队列,则仅在其他人遇到这种情况时使用用途:

(new InvoicesExport)->queue('invoices.xlsx')->onQueue('exports');

就像文档建议的laravel 8+,它将只使用自定义队列的QueueExport作业,您需要使用allOnQueue的自定义队列将用于其他作业

(new InvoicesExport)->queue('invoices.xlsx')->allOnQueue('exports');

相关问题