0

Using PartitionHandler to read multiple files and run synchronously. I did set 3 filenames in partitionmap after that when the step of item reader starts, It reads the same file again & again. Accessing the same file in Step execution context. do i need to specify anything to read all files instead of one file.??

Any help could be really appreciated. Please find my map and item reader as below:

Map<String, ExecutionContext> partitionMap = new HashMap<String, ExecutionContext>();

 for (File file : files) {              
    context.put("inputFile", file);
    partitionMap.put(file.getName(), context);
    System.out.println("files");
}

Here Iam setting list of files in the partitionMap.

Please find my job as follows:

<batch:job id="FileJob" incrementer="uniqueRunIdParameterGenerator" restartable="true">

    <batch:step id="readerInfo">
    <batch:partition step="read" partitioner="myPartitioner">
    </batch:partition>
    </batch:step> 
</batch:job>

<batch:step id="read">
    <batch:tasklet transaction-manager="transactionManager">
        <batch:chunk reader="flatFileItemReader"   writer="itemWriter" 
        commit-interval="10" >
         <batch:listeners>
            <batch:listener ref="itemFailureLoggerListener"/>
         </batch:listeners>
        </batch:chunk>
    </batch:tasklet>
</batch:step> 

<bean id= "myPartitioner" class="com.abc.batch.partitioner.MyBatchPartitioner" scope="step"></bean>

As i said it is running same file.I would like to run all files with 1 file at a time.

aschipfl
  • 33,626
  • 12
  • 54
  • 99
Alekya
  • 31
  • 2

0 Answers0