Java Reference
In-Depth Information
CustomerRowMapper you coded in Listing 9-55, along with the CustomerEmailConverter from Listing 9-56
as the ItemProcessor, and finally SimpleMailMessageItemWriter as the ItemWriter. Listing 9-60 shows the
configuration of the beans required for step 2 along with the job configuration.
Listing 9-60. Step2 and the Job Configuration
<beans:bean id="customerItemReader"
class="org.springframework.batch.item.database.JdbcCursorItemReader">
<beans:property name="dataSource" ref="dataSource"/>
<beans:property name="sql" value="select * from customer"/>
<beans:property name="rowMapper" ref="customerRowMapper"/>
</beans:bean>
<beans:bean id="customerRowMapper"
class="com.apress.springbatch.chapter9.CustomerRowMapper"/>
<beans:bean id="simpleEmailWriter"
class="org.springframework.batch.item.mail.SimpleMailMessageItemWriter">
<beans:property name="mailSender" ref="javaMailSender"/>
</beans:bean>
<beans:bean id="emailConverter"
class="com.apress.springbatch.chapter9.CustomerEmailConverter"/>
<step id="importFileStep">
<tasklet>
<chunk reader="customerFileReader" writer="jdbcBatchWriter"
commit-interval="10"/>
</tasklet>
</step>
<step id="emailCustomersStep">
<tasklet>
<chunk reader="customerItemReader" processor="emailConverter"
writer="simpleEmailWriter" commit-interval="10"/>
</tasklet>
</step>
<job id="formatJob">
<step id="step1" parent="importFileStep" next="step2"/>
<step id="step2" parent="emailCustomersStep"/>
</job>
That's all there is to it! You can build this job with mvn clean install from the command line and
run it with the command listed in Listing 9-61 to process the input file and send out the e-mails.
Listing 9-61. Executing the E-mail Job
java -jar itemWriters-0.0.1-SNAPSHOT.jar jobs/emailFormatJob.xml formatJob
customerFile=/input/customerWithEmail.csv
 
Search WWH ::




Custom Search