0
votes

I have configured a Scheduler to invoke my job at a specific interval ( for testing purposes I have tried with 30-second intervals). It is successfully invoking the job without any issue. But once the job execution is a success during the first run It does not re-run the step again( Although I have passed a new job parameter in each invoke). I want to run the same step even it is completed as there might be new data in the source DB. I have tried

.allowStartIfComplete(true)

But It did not invoke the reader in the step.

the primary requirement is to rerun the same batch job steps either it is exited successfully or not

@Scheduled(fixedRate=30*1000)
@SchedulerLock(name = "job-1", lockAtLeastFor = "15S", lockAtMostFor = "20S")
public void batchJob() throws InterruptedException {
JobParameters Parameters = new JobParametersBuilder()
    .addLong("startAt", System.currentTimeMillis()).toJobParameters();
try {
    jobLauncher.run(job, Parameters);
} catch (JobExecutionAlreadyRunningException | JobRestartException
    | JobInstanceAlreadyCompleteException | JobParametersInvalidException e) {

    e.printStackTrace();
}

}

     // Executes the job
  @Bean
  public Job jobUpdate(JobCompletionNotificationListener listener, Step step1) {
    return this.jobBuilderFactory.get("employee")
        .listener(listener)
        .incrementer(new RunIdIncrementer())
        .start(step1)
        .build();
  }


  @Bean
  public Step step1() {
    return stepBuilderFactory.get("step1")
        .allowStartIfComplete(true)
        .<Employee, Employee>chunk(2)
        .reader(reader())
        .processor(processor())
        .faultTolerant().skipPolicy(httpClientExceptionSkipper())
        .writer(compositeItemWriter())
        .build();
  }

Really Appreciate it if someone could shed some light on this.