title: Can Spring Retry be used with Spring Batch FlatFileItemReader
body: <p>I have the following <code>ItemReader</code>:</p>
  
  <pre><code>import org.springframework.batch.item.ExecutionContext;
  import org.springframework.batch.item.ItemStreamException;
  import org.springframework.batch.item.file.FlatFileItemReader;
  import org.springframework.batch.item.file.LineMapper;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.core.io.FileSystemResource;
  import org.springframework.retry.annotation.Retryable;
  import org.springframework.stereotype.Service;
  
  @Service
  public class MyReader extends FlatFileItemReader&lt;Holding&gt; {
  
      @Autowired
      public MyReader(LineMapper&lt;Holding&gt; lineMapper, File loadFile) {
          setResource(new FileSystemResource(loadFile));
          final int NUMBER_OF_HEADER_LINES = 1;
          setLinesToSkip(NUMBER_OF_HEADER_LINES);
          setLineMapper(lineMapper);
      }
  
      @Override
      @Retryable(value=ItemStreamException.class, maxAttempts=5,  backoff=@Backoff(delay=1800000))
      public void open(ExecutionContext executionContext) throws ItemStreamException {
                  super.open(executionContext);
      }
  }
  </code></pre>
  
  <p>The file to be read (i.e. <code>loadFile</code>) may or may not be available when running the job. If the file is not available, I want the reader to sleep ~30 minutes and then retry opening the file. If after five attempts, the file is not found it can fail as it normally would by throwing <code>ItemStreamException</code>. </p>
  
  <p>Unfortunately, the above code does not attempt to retry opening the file. It throws <code>ItemStreamException</code> on the first call to open and does not retry open. </p>
  
  <p>Can someone please explain how to do this? Note: I do have <code>@EnableRetry</code> on the <code>SpringBootApplication</code> class.</p>