title: Repeat tasklet step until certain condition
body: <p>I used Spring batch to build a ETL job. My main job is simply read from a db and write to another one. Before my main job, I need to check a status in the source db to see if it is ready or not. I will proceed with the main job only if the source db is ready. I implemented the check status logic as a Tasklet and I build my job with the simple logic that if check status step failed repeat this step util the step succeed, then proceed with the main job. I build the job as follows: </p>
  
  <pre><code>@Bean
  public Job myJob(MyListener listener) {
  
      return jobBuilderFactory.get(jobName)
                              .incrementer(new RunIdIncrementer())
                              .listener(listener)
                              .start(checkStatusStep())
                              .on("*").to(mainStep())
                              .on(ExitStatus.FAILED.getExitCode())
                              .to(checkStatusStep())
                              .end()
                              .build();
  }
  </code></pre>
  
  <p>The check status step is a tasklet as follows:</p>
  
  <pre><code>@Override
  public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws InterruptedException {
      //isReady method check the db to see if it is ready
      if (isReady()) {
          //contribution.setExitStatus(ExitStatus.COMPLETED);
          return RepeatStatus.FINISHED;
      } else {
          //contribution.setExitStatus(ExitStatus.FAILED);
          return RepeatStatus.CONTINUABLE;
      }
  }
  </code></pre>
  
  <p>I read the spring batch document and get that the ON method in the conditional follow will check the exit status of the step so that I set the exit status in the StepContribution. What makes me confused is that <strong>when I comment those two lines out and the code still works.</strong> </p>
  
  <p>So my question is, first, if the conditional flow checks the exit status why my code works without explicitly change the exit status? Second, why tasklet return a repeat status and by whom this repeat status is consumed.
  Third, is there a better way to achieve my goal?</p>