Reputation: 335
my code able to read and write to database but only one chunk after that this process stops. fail to execute other chunks.
here is the error looks like org.springframework.dao.InvalidDataAccessResourceUsageException: Unexpected cursor position change.
Step Implementation
@Bean
public Step step(StepBuilderFactory stepBuilderFactory) throws Exception {
ThreadPoolTaskExceutor taskExcutorInstance = new ThreadPoolTaskExceutor();
taskExcutorInstance.setCorePoolSize(10);
taskExcutorInstance.setMaxPoolSize(10);
return stepBuilderFactory
.get("read from DB and Write to DB")
.<Object, Object>chunk(1000)
.reader(reader(null))
.writer(writer())
.taskExecutor(taskExcutorInstance)
.build();
}
for reader im using JdbcCursorItemReader and for writer im using JdbcbatchItemWriter. I'm trying to read and write multiple chuncks at the same time
if I need to disable verifyCursorPosition how exactly we need disable this ?
Upvotes: 1
Views: 694
Reputation: 31600
The JdbcCursorItemReader
extends AbstractItemCountingItemStreamItemReader
which is NOT thread-safe. You can try to synchronize its read
operation (by decorating it with a SynchronizedItemStreamReader
), otherwise you need to use a thread-safe reader like the JdbcPagingItemReader
.
Upvotes: 3