8
votes

I'm Using Spring Batch to run my JOBS when the reader is org.springframework.batch.item.database.JpaPagingItemReader

And my JOB configured with the parameter: throttle-limit="6"

Is there any threads data conflict when reading data from the reader?

why i'm reviving the following warning:

[org.springframework.batch.core.step.item.ChunkMonitor:109] - No ItemReader set (must be   concurrent step), so ignoring offset data.
[org.springframework.batch.core.step.item.ChunkMonitor:141] - ItemStream was opened in a different thread.  Restart data could be compromised.
[org.springframework.batch.core.step.item.ChunkMonitor:141] - ItemStream was opened in a different thread.  Restart data could be compromised.
[org.springframework.batch.core.step.item.ChunkMonitor:141] - ItemStream was opened in a different thread.  Restart data could be compromised.
1

1 Answers

6
votes

While the JpaPagingItemReader is thread safe in that using it to read from multiple threads is ok, that reader will not support restart when used via multiple threads. The warnings are really there to indicate that you need to set the save state to false (JpaPaginingItemReader#setSaveState(boolean)). The documentation for this class discusses the need to set save state to false here: http://docs.spring.io/spring-batch/trunk/apidocs/org/springframework/batch/item/database/JpaPagingItemReader.html

The reason for this is that the restart state ends up being shared across all threads so they end up stepping on each other.