What's New in Spring Batch 2.X.X

The Spring Batch 2.0 release has six major themes: -

This new 'conditional flow' support is made easy to configure via the new namespace:
<job id="job">
    <step id="stepA">
        <next on="FAILED" to="stepB"></next>
        <next on="*" to="stepC"></next>
    </step>
    <step id="stepB" next="stepC"></step>
    <step id="stepC"></step>
</job>
conditional-flow
In 2.x.x, this strategy has been changed to a chunk-oriented approach:
conditional-flow

 Using the same example from above, if the commit interval is five, read will be called 5 times, and write once. The items read will be aggregated into a list, that will ultimately be written out, as the simplified example below illustrates:
List items = new Arraylist();
for(int i = 0; i &lt; commitInterval; i++){
    items.add(itemReader.read());
}
itemWriter.write(items);
In previous version 1.x.x, Steps had only two dependencies, ItemReader and ItemWriter:
conditional-flow
The basic configuration above is fairly robust. However, there are many cases where the item needs to be transformed before writing. In version 1.x.x this can be achieved using the composite pattern:
conditional-flow
This approach works. However, it requires an extra layer between either the reader or the writer and the Step. Furthermore, the ItemWriter would need to be registered separately as an ItemStream with the Step. For this reason, in the version 2.x.x the ItemTransfomer was renamed to ItemProcessor and moved up to the same level as ItemReader and ItemWriter:
conditional-flow




<<Introduction to spring batch process<< |index| >>The Domain Language of Batch






Labels: