I have below use case where we have to do the following using spring batch.
- Read big file
- process each records/line from file
- write it to DB
Currently it is single thread and working fine but i want to make it multithread where multiple thread will process and write to DB.
I have following approaches .
- if I use itemReader, itemProcessor, itemWrite then reading file using multiple thread is not a good idea and might degrade the performance. where multiple thread will reading same file using itemReaderClass.
- Second solution is , in 'step1' i read file and place in BlockingQueue and in 'step2' would
be multithread where i read,process,write from BlockingQueu.Then run 'step1' and 'step2' in parallel. so 'step1' is single threaded producer and 'step2' is multi threaded consumer.
Please suggest which one is right way to do it.