0
votes

I have to configure a job using Spring Batch. Is it possible to have a single threaded ItemReader but But Multi Threaded processor?

In this case ItemReader will create the work-items to be processed by reading it from database (by executing predefined query) and each processor will process item/chunk in parallel.

1

1 Answers

1
votes

Take a look at the AsyncItemProcessor and AsyncItemWriter from the spring-batch-integration module. What those do is the AsyncItemProcessor is executed in a different thread, returning a Future. The AsyncItemWriter then unwraps the Future and writes the result. You can read more about this in the documentation here: https://docs.spring.io/spring-batch/apidocs/org/springframework/batch/integration/async/AsyncItemProcessor.html