Categories: Spring Batch3Tutorial

What’s New in Spring Batch 3.0

The Spring Batch 3.0 release has five major themes:
  • JSR-352 Support
  • Upgrade to Support Spring 4 and Java 8
  • Promote Spring Batch Integration to Spring Batch
  • JobScope Support
  • SQLite Support

JSR-352 Support-

JSR-352 is the new java specification for batch processing. Heavily inspired by Spring Batch, this specification provides similar functionality to what Spring Batch already supports. However, Spring Batch 3.0 has implemented the specification and now supports the definition of batch jobs in compliance with the standard. An example of a batch job configured using JSR-352’s Job Specification Language (JSL) would look like below:

<?xml version="1.0" encoding="UTF-8"?>
<job id="myJob3" xmlns="http://xmlns.jcp.org/xml/ns/javaee" version="1.0">
    <step id="step1" >
        <batchlet ref="testBatchlet" />
    </step>
</job>

It is important to point out that Spring Batch does not just implement JSR-352. It goes much further than the spec in a number of ways:

  • Components – Spring Batch provides 17 different ItemReader implementations, 16 ItemWriter implementations, and many other components that have years of testing in production environments under their belts.
  • Scalability – JSR-352 provides scaling options for a single JVM only (partitioning and splits both via threads). Spring Batch provides multi-JVM scalability options including remote partitioning and remote chunking.
  • Spring dependency injection – While JSR-352 provides a form of “dependency injection light”, there are a number of limitations that it places on the construction of batch artifacts (must use no-arg constructors for example). Spring Batch is built on Spring and benefits from the power of the Spring Framework’s capabilities.
  • Java based configuration – While Spring’s XML based configuration options are well known, Spring and specifically Spring Batch, provide the option to configure your jobs using the type safety of java based configuration.
  • Hadoop/Big Data integration – Spring Batch is a foundational tool for interacting with Hadoop and other big data stores in the Spring ecosystem. Spring for Apache Hadoop provides a number of batch related extensions to use Spring Batch to orchestrate work on a Hadoop cluster. Spring XD builds on Spring Batch by providing both execution capabilities, but also management functionality similar to Spring Batch Admin for any environment.

Spring will continue to participate in the evolution of JSR-352 as it goes through maintenance revisions and look forward to further contributions to the JCP process.

Upgrade to Support Spring 4 and Java 8

With the promotion of Spring Batch Integration to be a module of the Spring Batch project, it has been updated to use Spring Integration 4. Spring Integration 4 moves the core messaging APIs to Spring core. Because of this, Spring Batch 3 will now require Spring 4 or greater.

As part of the dependency updates that have occurred with this major release, Spring Batch now supports being run on Java 8. It will still execute on Java 6 or higher as well.

Promote Spring Batch Integration to Spring Batch

Spring Batch Integration has been a sub module of the Spring Batch Admin project now for a few years. It provides functionality to better integrate the capabilities provided in Spring Integration with Spring Batch. Specific functionality includes:

  • Asynchronous ItemProcessor/ItemWriter – Executes the ItemProcessor logic on another thread, returning a Future to the ItemWriter. Once the Future returns, the result is written.
  • JobLaunchingMessageHandler/JobLaunchingMessageGateway – Provides the ability to launch jobs via Spring Messages received over channels.
  • Remote Chunking – Provides the ability to execute ItemProcessor logic remotely (across multiple JVMs) via a master/slave configuration.
  • Remote Partitioning – Provides the ability to execute full chunks remotely (read/process/write across multiple JVMs) via a master/slave configuration.

JobScope Support

The Spring scope “step” used in Spring Batch has had a pivotal role in batch applications, providing late binding functionality for a long time now. With the 3.0 release Spring Batch now supports a “job” scope. This new scope allows for the delayed construction of objects until a Job is actually launched as well as providing a facility for new instances for each execution of a job.

SQLite Support

SQLite has been added as a newly supported database option for the JobRepository by adding job repository ddl for SQLite. This provides a useful, file based, data store for testing purposes.

References

http://docs.spring.io/spring-batch/trunk/reference/html/whatsNew.html
https://spring.io/blog/2014/02/24/spring-batch-3-0-milestone-3-released

Previous
Next
Dinesh Rajput

Dinesh Rajput is the chief editor of a website Dineshonjava, a technical blog dedicated to the Spring and Java technologies. It has a series of articles related to Java technologies. Dinesh has been a Spring enthusiast since 2008 and is a Pivotal Certified Spring Professional, an author of a book Spring 5 Design Pattern, and a blogger. He has more than 10 years of experience with different aspects of Spring and Java design and development. His core expertise lies in the latest version of Spring Framework, Spring Boot, Spring Security, creating REST APIs, Microservice Architecture, Reactive Pattern, Spring AOP, Design Patterns, Struts, Hibernate, Web Services, Spring Batch, Cassandra, MongoDB, and Web Application Design and Architecture. He is currently working as a technology manager at a leading product and web development company. He worked as a developer and tech lead at the Bennett, Coleman & Co. Ltd and was the first developer in his previous company, Paytm. Dinesh is passionate about the latest Java technologies and loves to write technical blogs related to it. He is a very active member of the Java and Spring community on different forums. When it comes to the Spring Framework and Java, Dinesh tops the list!

Share
Published by
Dinesh Rajput

Recent Posts

Strategy Design Patterns using Lambda

Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…

2 years ago

Decorator Pattern using Lambda

Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…

2 years ago

Delegating pattern using lambda

Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…

2 years ago

Spring Vs Django- Know The Difference Between The Two

Technology has emerged a lot in the last decade, and now we have artificial intelligence;…

2 years ago

TOP 20 MongoDB INTERVIEW QUESTIONS 2022

Managing a database is becoming increasingly complex now due to the vast amount of data…

2 years ago

Scheduler @Scheduled Annotation Spring Boot

Overview In this article, we will explore Spring Scheduler how we could use it by…

2 years ago