Java Reference
In-Depth Information
<chunk reader="jmsReader" writer="xmlOutputWriter" commit-interval="10"/>
</tasklet>
</step>
<job id="formatJob">
<step id="step1" parent="formatFileInputStep" next="step2"/>
<step id="step2" parent="formatFileOutputStep"/>
</job>
That's all it takes! With all the resources configured, building and running this job is no different
than any of the others you've executed. However, when you run this job, notice that nothing obvious is
outputted from step 1 to tell you that anything happened besides looking into the JobRepository or
browsing the queue before the second step executes. When you look at the XML generated in step 2, you
can see that the messages have successfully been passed through the queue as expected. Listing 9-51
shows a sample of the XML generated by this job.
Listing 9-51. Sample Output from the JMS Version of formatJob
<?xml version="1.0" encoding="UTF-8"?>
<customers>
<customer>
<id>0</id>
<firstName>Richard</firstName>
<middleInitial>N</middleInitial>
<lastName>Darrow</lastName>
<address>5570 Isabella Ave</address>
<city>St. Louis</city>
<state>IL</state>
<zip>58540</zip>
</customer>
<customer>
<id>0</id>
<firstName>Warren</firstName>
<middleInitial>L</middleInitial>
<lastName>Darrow</lastName>
<address>4686 Mt. Lee Drive</address>
<city>St. Louis</city>
<state>NY</state>
<zip>94935</zip>
</customer>
...
</customers>
By using Spring's JmsTemplate , Spring Batch exposes the full power of Spring's JMS processing
capabilities to the batch processes with minimal effort. The next section looks at a writer you may not
have thought about: it lets you send e-mail from batch processes.
SimpleMailMessageItemWriter
The ability to send an e-mail may sound very useful. Heck, when a job completes, it might be handy to
receive an e-mail that things ended nicely. However, that isn't what this ItemWriter is for. It's an
 
Search WWH ::




Custom Search