title: Spring Batch - reading multiple PDF files and passing them to ItemProcessor
body: <p>I would like to read a multiple pdf files and process them one by one.</p>
  
  <p>I use MultiResourceItemReader and a custom delegate:</p>
  
  <pre><code>public class MyItemReader implements ResourceAwareItemReaderItemStream&lt;MyItem&gt; {
  
      private Resource resource;
  
      @Override
      public MyItem read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {
          return null; //create MyItem
      }
  
      @Override
      public void setResource(Resource resource) {
          this.resource = resource;
      }
  
      @Override
      public void open(ExecutionContext executionContext) throws ItemStreamException {
      }
  
      @Override
      public void update(ExecutionContext executionContext) throws ItemStreamException {
      }
  
      @Override
      public void close() throws ItemStreamException {
      }
  }
  </code></pre>
  
  <p>The problem I have is that the read method is ivoked infinitly and my ItemProcessor is not invoked.
  The resources property is correctly set - files are set.
  Could anyone explain me this? Thanks in advance.</p>
  
  <p>I finally decided to use ResourcesItemReader instead of MultiResourceItemReader with custom delegate. This solution is simpler.</p>
  
  <pre><code>&lt;!--suppress SpringBatchModel --&gt;
  &lt;batch:job id="my-import"&gt;
      &lt;batch:step id="myFileStep"&gt;
          &lt;batch:tasklet&gt;
              &lt;batch:chunk reader="resourcesItemReader"
                           processor="sddeImportProcessor"
                           writer="sddeImportJpaItemWriter"
                           commit-interval="${commit.interval:500}"/&gt;
          &lt;/batch:tasklet&gt;
      &lt;/batch:step&gt;
      &lt;batch:listeners&gt;
          &lt;batch:listener ref="sftpImportExecutionListener"/&gt;
          &lt;batch:listener ref="longRunningJobExecutionNotificator"/&gt;
          &lt;batch:listener ref="exitStatusJobExecutionListener"/&gt;
          &lt;batch:listener ref="afterJobExecutionMailSender"/&gt;
      &lt;/batch:listeners&gt;
  &lt;/batch:job&gt;
  
  &lt;bean id="sftpImportExecutionListener"
        class="my.batches.shared.listener.SftpImportJobListener"&gt;
      &lt;constructor-arg name="ftsReadService" ref="ftsReadService"/&gt;
      &lt;constructor-arg name="ftsWriterService" ref="ftsWriterService"/&gt;
      &lt;constructor-arg name="localDir" value="${voe.batch.sdde.unterschriftenblatt.import.local.folder}"/&gt;
      &lt;constructor-arg name="remoteDir" value="${voe.batch.sdde.unterschriftenblatt.import.remote.folder}"/&gt;
      &lt;constructor-arg name="multipleFilesImport" value="true" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="resourcesItemReader" class="org.springframework.batch.item.file.ResourcesItemReader" scope="step"&gt;
      &lt;property name="resources" value="#{jobExecutionContext['import.input.file.path']}"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="myImportProcessor" class="my.MyProcessor"&gt;
      &lt;property name="myUpdateService" ref="defaultUpdateService" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="myImportJpaItemWriter" class="org.springframework.batch.item.database.JpaItemWriter"&gt;
      &lt;property name="entityManagerFactory" ref="entityManagerFactory"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p>