[英]GCP storage - read data from mongo db and write it into to file GCP bucket
[英]Spring batch reader changes to read file content from GCP cloud storage bucket
我有一个像这样的预先存在的 springboot 应用程序,它使用spring 批处理从本地位置读取一个巨大的 CSV 文件(大小 = 1GB),并在对数据库进行一些更改后插入内容。 现在,该文件将来自 Google Cloud Platform (GCP) 中的存储桶。 我打算使用这里提到的入站流通道适配器之类的东西。 这可行吗?如果可行,该批次的ItemReader 中需要进行哪些更改? 还是我需要考虑其他选择? 欢迎任何建议。
FlatFileItemReader
适用于任何Resource
实现。 因此,您可以使用URLResource
并将其指向您在 GCP 上的文件,而无需下载它。
下面是使用 URLResource 的 CSV 文件的具体示例:
URLResource ur = new URLResource("http://www.dukelearntoprogram.com/course2/java/food.csv");
for (CSVRecord record : ur.getCSVParser()) {
// print or process fields in record
String name = record.get("Name");
// other processing
}
这是从非官方文档中提取的。
通过添加相关依赖和更改本地文件路径
->"flatFileItemReader.setResource(new FileSystemResource("src/main/resources/message.csv"));"
对此
->"flatFileItemReader.setResource(new UrlResource("storage.googleapis.com/test-mybucket/mycsv.csv"));"
它会工作吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.