Context: I am working on Spring Batch pipeline which will upload data to database. I have already figured out how to read flat .csv
files and write items from it with JdbcBatchItemWriter
. The pipeline I am working on must read data from Zip archive which contains multiple .csv
files of different types. I'd like to have archive downloading and inspecting as two first steps of job. I do not have enough disk space to unpack the whole loaded archive. Instead of unpacking, I inspect zip file content to define .csv
files paths inside Zip file system and their types. Zip file inspecting allows obtaining InputStream
of corresponding csv
file easily. After that, reading and uploading (directly from zip) all discovered .csv
files will be executed in separate steps of the job.
Question: Is there any way to dynamically populate new Step
s for each of discovered csv
entries of zip at job runtime as result of inspect
step?
Tried: I know that Spring Batch has conditional flow but it seems that this technique allows configuring only static number of steps that are well defined before job execution. In my case, the number of steps (csv
files) and reader types are discovered at the second step of the job.
Also, there is a MultiResourceItemReader which allows to read multiple resources sequentially. But I'm going to read different types of csv
files with appropriate readers. Moreover, I'd like to have "filewise" step encapsulation such that if one file loading step fails, others will be executed anyway.
The similar question How to create dynamic steps in Spring Batch does not have suitable solution for me as the answer supposes steps creation before job running, while I need to add steps as result of second step of job.