title: Restarting a spring batch job that is run by multiple threads
body: <p>We have a requirement where we read from a file, porocess it and write to a flat file. My question is would FlatFileItemReader keep track of the records it processed so that if job fails in the middle it can pick up where it failed. </p>
  
  <p>For example let's say the throttle limit is 2 and commit-interval is 10 and my file has 20 records. Let's say thread1 is processing 1st 10 records and 
  thread2 is processing next 10 records. If all 10 records by thread2 are processed succesfully and thread1 failed because of one bad record and hence the entire job failed. Next time 
  when the job is restarted how the spring would identify unprocessed records? </p>
  
  <p>What is a better way to process the file using multiple threads and at the same time be able to start over when failed in the middle. </p>
  
  <pre><code>&lt;batch:job job-repository="jobRepository" id="insertIntoCsvFromCsvJob"&gt;
          &lt;batch:step id="step1"&gt;
              &lt;batch:tasklet transaction-manager="transactionManager"
                  task-executor="taskExecutor" throttle-limit="${throttle-limit}"&gt;
                  &lt;batch:chunk reader="csvFileItemReader" writer="customWriter" processor="compositeProcessor
                      commit-interval="${commit-interval}" &gt;
                  &lt;/batch:chunk&gt;
              &lt;/batch:tasklet&gt;
          &lt;/batch:step&gt;
      &lt;/batch:job&gt;
  
      &lt;bean id="csvFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader"&gt;
           &lt;property name="resource" value="classpath:files/input.csv" /&gt;         
          &lt;property name="lineMapper" ref="fieldSetMapper" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="csvFileItemWriter" class="org.springframework.batch.item.file.FlatFileItemWriter"&gt;
          &lt;property name="resource" value="file:c:/outout.csv" /&gt;
          &lt;property name="shouldDeleteIfExists" value="true" /&gt;
          &lt;property name="lineAggregator" ref="lineAggregator" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="taskExecutor" class="org.springframework.core.task.SimpleAsyncTaskExecutor" /&gt;
  </code></pre>