0
votes

In spring Batch doc (http://docs.spring.io/spring-batch/reference/html/scalability.html), under 7.4.3 section it is given that we can set the 'resource' property of MultiResourceItemReader from stepExecutionContext. But there is no property called 'resource' in MultiResourceItemReader, instead it is 'resources'. Then how single resource can be set to MultiResourceItemReader from stepExecutionContext which will have single fileName in each context which was set during partitioning.

1

1 Answers

0
votes

Instead it's called resources (which is an array) and it can be set like so:

<bean id="multiResourceReader" 
            class=" org.springframework.batch.item.file.MultiResourceItemReader">
    <property name="resources" value="file:some/folder/prefix*.csv" />
    <property name="delegate" ref="flatFileItemReader" />
</bean>

When partitioning, you would not use a MultiResourceItemReader. Instead, just use a FlatFileItemReader in step scope.

<bean id="flatFileItemReader" scope="step"
            class="org.springframework.batch.item.file.FlatFileItemReader">
    <property name="resource" value="file:#{stepExecutionContext['FILE.NAME']}">
</bean>