How to implement File Update logic in Chunk Processing (Java Batch - JSR352)

做~自己de王妃 提交于 2019-12-13 03:17:58

问题


I am trying to develop a Java batch program using the IBM's JSR352 Implementation. Since the batch job involves iteratively processing huge number of records, I chose to implement it as Chunk Processing job.

This job involves of 3 steps which keeps repeated for each records in File 1

  1. Reader Class: Read content from File 1 to form a key text
  2. Processor Class: Look-up the Key text in File 2
  3. Writer Class: Update the text in File 2 where key text was found with a custom text

From the processor to writer, I can return all line numbers where the key text matches were found. But, without RandomAccess to file, how can i update those specific line numbers in File 2 from my Writer?

Since I am restricted to use only these Input/Outputstreams for file handling I am unable to split the Lookup & Update logic between processor & writer classes. How can i achieve this ?

This is because the code will be developed in a windows machine but, finally executed in a mainframe (z/os) server.


回答1:


The processor is technically optional, so you could merge the lookup/update logic in just the writer class. That might help.

On z/OS this is easier to do with a VSAM dataset (also accessible via the JZOS ZFile APIs). But that's going to be hard to develop/test on Windows. I suppose you could keep the ZFile calls separate and on Windows replace them with some rigged up emulation that would work well enough for testing purposes.




回答2:


I finally had to drop the JZOS FileFactory based approach and use the JZOS ZFile's locate API to find the the specific lines (using keys) and update it from the writer.



来源:https://stackoverflow.com/questions/45862640/how-to-implement-file-update-logic-in-chunk-processing-java-batch-jsr352

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!