Hi,
Hi,
I used ClassifierCompositeItemWriter for wirting into files based on the item grouping. Here I defined three item writers beans. Is there any other way to define one itemwriter bean, where I can append the map key along with the file name.
say for example,
1. read input file say input.txt
2. Need to write the output files as output_111.txt,output_222.txt,.output_333.txt, based on the mapper key specified and with one itemwriter bean.
In the below code I should have one itemWriter1 bean and able to write into three different files.
Code:<bean id="customWriting" class="org.springframework.batch.item.support.ClassifierCompositeItemWriter"> <property name="classifier"> <bean class="org.springframework.batch.classify.BackToBackPatternClassifier"> <property name="routerDelegate"> <bean class="com.util.ItemGrouping" /> </property> <property name="matcherMap"> <map> <entry key="111*" value-ref="itemWriter1" /> <entry key="222*" value-ref="itemWriter2" /> <entry key="333*" value-ref="itemWriter3" /> </map> </property> </bean> </property> </bean> <bean id="itemWriter1" class="org.springframework.batch.item.file.FlatFileItemWriter" scope="step"> <property name="lineAggregator" ref="lineAggregator" /> <property name="resource" value="file:./output.csv"/> <property name="shouldDeleteIfExists" value="true" /> </bean> <bean id="itemWriter2" class="org.springframework.batch.item.file.FlatFileItemWriter" scope="step"> ..... </bean> <bean id="itemWriter2" class="org.springframework.batch.item.file.FlatFileItemWriter" scope="step"> ..... </bean> <bean id="itemWriterDelegate" class="org.springframework.batch.item.file.FlatFileItemWriter" scope="step"> ..... </bean>


Reply With Quote