英文:
Create output file for each of input file from directory of files in Spring Batch
问题
我有一个包含交易信息的CSV文件目录。
我需要读取每个文件,处理一些业务逻辑(与数据库验证以检查帐户和交易是否有效),并将有效交易写入新的输出文件。
输入:
Tranx_100.csv,Tranx_101.csv,Tranx_102.csv...
输出:
Tranx_100_output.csv,Tranx_101_output.csv,Tranx_102_output.csv...
希望使用Spring Batch来实现这一点。对如何实现这一点有什么建议吗?
对于每个文件作为输入,处理和输出是相同的 - 我可以将它们作为步骤(Step)的一部分运行,并在作业(JOB)中重复执行这个步骤吗?
英文:
I have a directory of CSV files which contains transaction information.
I need to read each file , process some business logic (validate with DB to check valid account and transaction or not) and write the valid transactions into new output file.
Input:
Tranx_100.csv, Tranx_101.csv, Tranx_102.csv....
Ouput:
Tranx_100_output.csv, Tranx_101_output.csv, Tranx_102_output.csv....
Want to use spring batch for this. Any suggestions on how to implement this?
For each file as input, process, output are same - can i run them as part of 'Step' and repeat the step for each input file in a JOB?
答案1
得分: 0
不要回答我要翻译的问题。以下是要翻译的内容:
"Instead of looping on the same step or using multiple steps in a single job, I would use a job instance for each file (ie the file is an identifying job parameter) and launch jobs in parallel. This approach has multiple advantages:
- Fault-tolerance: In case of failure, only the failed file is re-processed
- Scalability: You can run multiple jobs in parallel easily
- Logging: logs will be separated by design
- And all the good reasons of making one thing do one thing and do it well"
英文:
Instead of looping on the same step or using multiple steps in a single job, I would use a job instance for each file (ie the file is an identifying job parameter) and launch jobs in parallel. This approach has multiple advantages:
- Fault-tolerance: In case of failure, only the failed file is re-processed
- Scalability: You can run multiple jobs in parallel easily
- Logging: logs will be separated by design
- And all the good reasons of making one thing do one thing and do it well
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论