Jan 1st, 2012, 10:31 PM
Reading 2 different files, with 2 different fomats in same job
I am new to the boards. I have worked on a few Spring batch projects but could use some experienced help regarding best practices or best ways to handle certain issues.
I need to configure a job that reads files from a file system, transforms the file to Java objects and then calls a web service on each record (or object).
My questions are
1. If I will be expecting 2 different file patterns in the same directory, for example A.txt that has a specific line format and B.txt that has its own line format, is there a way to configure a step's reader to call a separate LineMapper based on file type? Or should this be split into two parallel steps that each define their own FlatFileItemReader? (If done this way, both steps would use the same writer, which basically just calls a web service and doesn't expect a result back).
I have looked at the PatternMatchingCompositeLineMapper class and also the MultiResourceItemReader class but didnt find them relavent to my use case.
2. Instead of just calling the Web Service in the writer for each mapped object, would it be better practice to write each object to a staging queue per say, and then configure a parallel multithreaded step that listens on the queue and calls the web service for each item that is put on the queue?
Thanks in advance for any help on these issues.