job_beans.job_demo.xml Maven / Gradle / Ivy
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:b="http://www.springframework.org/schema/batch" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-3.0.xsd"> <!--<bean id="passThroughItemProcessor2" class="org.springframework.batch.item.support.PassThroughItemProcessor" ></bean>--> <bean id="demoEntity" class="se.ikama.bauta.demo.DemoEntity" scope="prototype" /> <bean id="demoReader" class="org.springframework.batch.item.file.FlatFileItemReader" > <property name="directory" value="file:/${bauta.dataDir}/demo/input.csv" /> <property name="linesToSkip" value="1" /> <property name="recordSeparatorPolicy"> <bean class="org.springframework.batch.item.file.separator.DefaultRecordSeparatorPolicy"/> </property> <property name="lineMapper"> <bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper"> <!-- split it --> <property name="lineTokenizer"> <bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer"> <property name="delimiter" value=","/> <property name="names" value="id,message" /> </bean> </property> <property name="fieldSetMapper"> <!-- return back to reader, rather than a mapped object. --> <!-- <bean class="org.springframework.batch.item.file.mapping.PassThroughFieldSetMapper" /> --> <!-- map to an object --> <bean class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper"> <property name="prototypeBeanName" value="demoEntity" /> </bean> </property> </bean> </property> </bean> <bean id="demoWriter" class="org.springframework.batch.item.file.FlatFileItemWriter"> <!-- write to this csv file --> <property name="directory" value="file:/${bauta.dataDir}/demo/output.csv" /> <property name="shouldDeleteIfExists" value="true" /> <property name="lineAggregator"> <bean class="org.springframework.batch.item.file.transform.DelimitedLineAggregator"> <property name="delimiter" value="," /> <property name="fieldExtractor"> <bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor"> <property name="names" value="id,message" /> </bean> </property> </bean> </property> </bean> <bean id="demoProcessor" class="se.ikama.bauta.demo.DemoProcessor"></bean> <b:job id="Job.01.ReadWriteDemo" restartable="false"> <b:step id="demo-import" > <b:description>Reads demo data frmo csv files and writes to elastic</b:description> <b:tasklet > <b:chunk reader="demoReader" writer="demoWriter" processor="demoProcessor" commit-interval="10" /> </b:tasklet> </b:step> </b:job> </beans>