I have a requirement to get the data from a database and write that data to files based on the filename given in the database.
This is how data is defined in the database:
Columns --> FILE_NAME, REC_ID, NAME
Data --> file_1.csv, 1, ABC
Data --> file_1.csv, 2, BCD
Data --> file_1.csv, 3, DEF
Data --> file_2.csv, 4, FGH
Data --> file_2.csv, 5, DEF
Data --> file_3.csv, 6, FGH
Data --> file_3.csv, 7, DEF
Data --> file_4.csv, 8, FGH
As you see, basically the file names along with the data is defined in the Database so what SpringBatch should do is get this data and write it to the corresponding file specified in the Database (i.e., file_1.csv
should only contain 3 records (1,2,3), file_2.csv
should only contain records 4 and 5, etc.)
Is it possible to use MultiResourceItemWriter
for this requirement (please note that entire file name is dynamic and needs to be retrieved from Database).