Java Reference
In-Depth Information
<beans:property name="dataSource" ref="dataSource"/>
<beans:property name="tableName" value="transaction"/>
<beans:property name="whereClause" value="where id = ?"/>
</beans:bean>
<beans:bean id="taskExecutor"
class="org.springframework.core.task.SimpleAsyncTaskExecutor">
<beans:property name="concurrencyLimit" value="10"/>
</beans:bean>
By taking the staged-record approach, you allow Spring Batch to not worry about the state of the
step because it's maintained separately. Unfortunately, this solution still isn't perfect because it's only
practical when you're using input sources that can be managed this way (databases are the typical use
case). Flat files can't be managed in a staged manner. In the end, however, most input situations can be
addressed in a way that allows for multithreaded processing.
Parallel Steps
Multithreaded steps provide the ability to process chunks of items within the same step of a job in
parallel, but sometimes it's also helpful to be able to execute entire steps in parallel. Take for example
importing multiple files that have no relationship to each other. There is no reason for one import to
need to wait for the other import to complete before it begins. Spring Batch's ability to execute steps and
even flows (reusable groups of steps) in parallel allows you to improve overall throughput on a job. This
section looks at how to use Spring Batch's parallel steps and flows to improve the overall performance of
your jobs.
If you think about submitting an order online, a number of things need to happen before the item is
put into the box and handed to the postman to be delivered to your door. You need to store the order.
Payment needs to be confirmed. Inventory needs to be validated. Pick lists need to be generated for the
item to be obtained from a warehouse and packed. But not all these pieces of work need to be performed
in order. As an example of parallel processing, let's look at a job that receives an order, imports it into a
database, and then in parallel verifies payment and inventory. If both are available, the order is
processed. Figure 11-14 shows a diagram of the process flow for this sample job.
Verify Credit
Preload Data
Load Orders
Process Order
Verify Inventory
Figure 11-14. Process flow for an order-processing job
 
Search WWH ::




Custom Search