Java Reference
In-Depth Information
To put this class to use, you need to begin building your job. Because the first step consists only of
generating Order s using OrderGenerator and writing them to a JMS queue, you can wire all that up and
test it without needing to go any further. Listing 11-8 shows the configuration of the job as a single-step
job that generates data and puts it on the queue for future steps to pick up.
Listing 11-8. Parallel Job Configured in parallelJob.xml with the First Step Configured
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns=" http://www.springframework.org/schema/batch"
xmlns:beans=" http://www.springframework.org/schema/beans"
xmlns:util=" http://www.springframework.org/schema/beans"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.1.xsd">
<beans:import resource="../launch-context.xml"/>
<beans:bean id="jmsWriter" class="org.springframework.batch.item.jms.JmsItemWriter">
<beans:property name="jmsTemplate" ref="jmsTemplate"/>
</beans:bean>
<beans:bean id="dataGenerator"
class="com.apress.springbatch.chapter11.processor.OrderGenerator"/>
<step id="preloadDataStep">
<tasklet>
<chunk reader="dataGenerator" writer="jmsWriter" commit-interval="10"/>
</tasklet>
</step>
<job id="parallelJob">
<step id="step1" parent="preloadDataStep"/>
</job>
</beans:beans>
Although the job itself is now configured, you need to make a couple of small tweaks to launch-
context.xml and your POM file for this job. Specifically, you need to configure JMS support and
Hibernate support (you use Hibernate for this job to simplify storing the object hierarchy) in launch-
context.xml and add the appropriate dependencies to your POM file. 2
Let's update the POM file first. Listing 11-9 shows the additional dependencies for ActiveMQ and
Spring's JMS support as well as the Hibernate dependencies and Spring's ORM supporting modules.
Listing 11-9. Updating the POM File to Support JMS and Hibernate
2 See Chapters 7 and 9 to learn more about using Hibernate and JMS in your jobs.
 
Search WWH ::




Custom Search