Oct 3rd, 2011, 04:27 PM
Multi-threaded steps will execute the whole step (ItemReader, ItemProcessor and ItemWriter) in parallel. This is often problematic because ItemReaders and ItemWriters are not thread-safe, and even when you make them thread-safe you loose record ordering and restartability if you don't resort to a process indicator pattern using a DB. But the ItemProcessor part of the step could in theory be done multi-threaded, while ItemReader and ItemWriter stay single-threaded. Is this possible in spring batch?
I also have a second question that is also related to ItemProcessor: in another batch job I need to call a webservice in the ItemProcessor, but this webservice provides a bulk interface, so I don't want to invoke it for every item, but rather I want to invoke it for the complete chunk. Is this possible?
Thanks in advance.
Oct 3rd, 2011, 11:07 PM
I am not very sure if making only the processor multithreaded is possible.
Regarding your second query, you should call the web service in the writer as the complete chunk will be availaible. This is the recommended approach for processing chunk of items.