Reputation: 1406
I have a spring batch job which takes-in flat file, processes the records and writes-out the output to another flat file.
I have used FlatFileItemReader
and FlatFileItemWriter
as reader and writer respectively.
However, when I try to implement multi-threaded steps, my job does not work properly. I get following warnings in my log file
WARN ChunkMonitor:109 - No ItemReader set (must be concurrent step), so ignoring offset data.
WARN ChunkMonitor:141 - ItemStream was opened in a different thread. Restart data could be compromised.
Can you please help me out in implementing multi-threaded step?
Upvotes: 2
Views: 4288
Reputation: 5409
This is because FlatFileItemReader is not thread-safe as the doc says :
/**
* Abstract superclass for {@link ItemReader}s that supports restart by storing
* item count in the {@link ExecutionContext} (therefore requires item ordering
* to be preserved between runs).
*
* Subclasses are inherently *not* thread-safe.
*
* @author Robert Kasanicky
*/
To implements a multi-thread reader, you will have to write a custom reader that synchronize the calls to open and update from the ItemStream interface. If not, your job won't be safe to be restartable.
Hope it helps
Regards
Upvotes: 2