title: spring batch - multiResourceItemReader: how to make job parameters unique and restart job
body: <p>I am using spring batch module to process csv files from a directory. Directory may contain multiple files with a specific extenstion and i am using MultiResourceItemReader to read the files.
  Job will receive 3 job parameters as read_from_directory, move_to_directory and a default_user_id. All these parameters will remain same for all the job runs. read_from_directory will contain 
  multiple csv files and job should process these files one after another. The problem i am facing is since job parameters are same i am getting JobInstanceAlreadyCompleteException when the job is run second time. I am aware this problem can be overcome by using an additional timestamp parameter to make job parameters unique. But since adding timestamp parameter will make every job instance unique i don't wish to use this approach because it will create issues in making my job restartable. 
  So i would like some suggestions on,</p>
  
  <ol>
  <li><p>How can i make each job instance unique without using timestamp parameter.           </p></li>
  <li><p>How the job can be made restartable in this case? Will adding 'restartable="true"' suffice or will it take some additional configuration/coding on my part. I am little bit confused here because job will read multiple files from a directory. So if a job fails, for example, due to an incorrect record in one of the file how can i restart the same job from where it left of? I have configured the job to run periodically, after a certain time interval, using a scheduler. So if job fails and then i rectify error in the csv file, will job start from where it left off when it runs next time?</p></li>
  </ol>
  
  <p>Please find below relevant part from my configuration:</p>
  
  <pre><code>&lt;batch:job id="testJob" restartable="true"&gt;
          &lt;batch:step id="step1"&gt;
              &lt;batch:tasklet&gt;
                  &lt;batch:chunk reader="multiResourceItemReader" writer="fileWriter"
                      commit-interval="1"&gt;
                  &lt;/batch:chunk&gt;
              &lt;/batch:tasklet&gt;
          &lt;/batch:step&gt;
      &lt;/batch:job&gt;
  
      &lt;bean id="fileWriter" class="com.ivish.TestFileWriter" /&gt;
      &lt;bean id="multiResourceItemReader" class="org.springframework.batch.item.file.MultiResourceItemReader" scope="step"&gt;
          &lt;property name="resources" value="file:#{jobParameters['read_from_directory']}/*.csv" /&gt;
          &lt;property name="delegate" ref="fileReader" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="fileReader" class="com.ivish.TestFileReader" scope="step"&gt;
          &lt;property name="delegate" ref="delegateFileReader" /&gt;
          &lt;property name="moveToDirectory" value="#{jobParameters['move_to_directory']}" /&gt;
      &lt;/bean&gt;
      &lt;bean id="delegateFileReader" class="org.springframework.batch.item.file.FlatFileItemReader"&gt;
          &lt;property name="lineMapper"&gt;
              &lt;bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper"&gt;
                  &lt;property name="lineTokenizer" ref="fileTokenizer" /&gt;
                  &lt;property name="fieldSetMapper"&gt;
                      &lt;bean
                          class="org.springframework.batch.item.file.mapping.PassThroughFieldSetMapper" /&gt;
                  &lt;/property&gt;
              &lt;/bean&gt;
          &lt;/property&gt;
      &lt;/bean&gt;         
  </code></pre>
  
  <p>Thank you.</p>