php - Laravel 延迟作业不适用于批处理
问题描述
我正在尝试延迟添加到我的 Laravel 应用程序中的批处理中的作业,但是在尝试添加延迟的作业时出错,我的代码中缺少什么?
/**
* Create chunked CSVs
*/
protected function createChunkedCSVs(Request $request)
{
try {
// get the CSV we stored
$data = file($request->csv);
// chunk the CSV into smaller csv's
$chunks = array_chunk($data, 1000);
// header and batch
$header = [];
$batch = Bus::batch([])->dispatch();
// latest form release
$release = $this->getApplicationFormVersion();
// begin chunking
foreach ($chunks as $key => $chunk) {
$data = array_map('str_getcsv', $chunk);
if ($key === 0) {
$header = $data[0];
unset($data[0]);
}
$batch->add(new CustomersCsvProcess($data, $header, $release)->delay(Carbon::now()->addMinutes(5)));
}
// return the batch
return $batch;
} catch (\Exception $e) {
return null;
}
}
解决方案
推荐阅读
- excel - 如何通过 Excel VBA 自动单击 Internet Explorer 11 中的“保存”按钮
- php - 我正在尝试更改 WordPress 主题中的占位符,但找不到它的存在位置
- java - Maven 找不到自定义注解处理器
- c++ - 在 std::thread 中使用分配的结构数据
- html - XMLHTTP60 Req 未显示整个 HTML 文档
- javascript - find.find() 和 browser.find.highlightResults() 不适用于 firefox 61 扩展
- angular - 如何使用服务调用孙组件中的函数
- scala - Spark:将每一行数据帧与另一个数据帧的所有行连接起来的方法
- java - 使用 CriteriaQuery 时如何限制结果
- .htaccess - 使用 htaccess 文件从一个域重定向到另一个域