[英]Spring Batch: Reading database and writing into multi record Flat files
Hi I am doing POC/base for design on reading database and writing into flat files. 嗨,我正在做POC /基础设计,用于读取数据库和写入平面文件。 I am struggling on couple of issues here but first I will tell you the output format of flat file 我在这里要解决几个问题,但首先我将告诉您平面文件的输出格式
Please let me know how do design the input writer where I need to read the transactions from different tables, process records , figure out the summary fields and then how should I design the Item Writer which has such a complex design. 请让我知道如何设计输入编写器,在这里我需要从不同的表中读取事务,处理记录,找出摘要字段,然后如何设计具有如此复杂设计的项目编写器。 Please advice. 请指教。 I am successfully able to read from single table and write to file but the above task looks complex. 我可以成功地从单个表读取并写入文件,但是上述任务看起来很复杂。
Extend the FlatFileItemWriter
to only open a file once and append to it instead of overwriting it. 扩展FlatFileItemWriter
仅打开一个文件并将其追加到文件,而不是覆盖它。 Then pass that same filewriter into multiple readers in the order you would like them to appear. 然后按照您希望它们出现的顺序将同一个文件编写器传递给多个阅读器。 (Make sure that each object read by the readers are extensible by something that the writer understands! Maybe interface BatchWriteable
would be a good name.) (确保读者能够读取的每个对象都可以被作者理解的东西扩展!也许interface BatchWriteable
是一个好名字。)
Some back-of-the-envelope pseudocode: 一些信封后面的伪代码:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.