Skip to content
Advertisement

Spring Batch Item Reader is executing only once

Trying to implement Spring batch,but facing a strange problem,Our ItemReader class is executing only once.

Here below is the detail.

  1. If we have 1000 rows in DB.
  2. Our Item reader fetch 1000 rows from DB,and pass list to ItemWriter
  3. ItemWriter successfully delete all items.
  4. Now ItemReader again tries to fetch the data from DB,but did not find,hence returns NULL,so execution stops.
  5. But we have configured batch to be executed with Quartz scheduler,which is every minute.
  6. Now if we insert let say 1000 rows in DB by dump import,the batch job should pick this data in next execution,but it is not even executing,although JobLauncher is executing.

Configuration :

1.We have ItemReader,ItemWriter with commit interval equals to 1.

JavaScript

2.Job is scheduled to be triggered at every minute.

JavaScript

3.Job configuration

JavaScript

First time it is executing successfully,but later it does not execute,but i can see in logs that JobLauncher is executing.

JavaScript

EDIT:–

JavaScript

Advertisement

Answer

After hours of time wasting,the problem seems to be solved now,i have configured allow-start-if-complete="true" in tasklet.Now Batch Item Reader is executing as per schedule.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement