Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Advantages of spring batch [closed]

I understood that spring batch framework processes data in chunks. However, I was thinking that when the same chunking functionality can be acheived through java why do we need to go for batch framework.

Could any one please let me know if there are more reasons for going to spring batch framework?

like image 456
Skanda Avatar asked Nov 14 '14 11:11

Skanda


People also ask

What is the purpose of Spring Batch?

Spring Batch provides reusable functions that are essential in processing large volumes of records, including logging/tracing, transaction management, job processing statistics, job restart, skip, and resource management.


1 Answers

Let me rephrase your question a bit and see if this addresses it.

What does Spring Batch provide that I'd have to handle myself when building a batch application?

Spring Batch served as the basis for JSR-352 (the java batch specification) and since that specification has come out, there is a lot of Spring Batch now available within the java space. That being said, there is still a lot that Spring Batch provides outside of the scope of what basic Java does:

Within a "basic" batch job

Within the scope of a simple batch job, Spring Batch provides a collection of utilities and implementations that have been battle tested in all enterprise verticals. Some examples are:

  • Over 17 ItemReader and 15 ItemWriter implementations covering vast options for input and output (File, JDBC, NoSQL, JMS, etc). All of these provide declarative I/O options so that you don't have to write and test code for stateful readers and writers.
  • A collection of Tasklet (Spring Batch's equivalent to JSR-352's Batchlet) implementations including ones for executing shell commands and interfacing with Hadoop.
  • The ability to stop/start/restart jobs and maintain state between executions.
  • The ability to skip and retry records as they are being processed.
  • Transaction management. Spring Batch handles transactions for you.
  • The ability to notify other systems when errors occur via messaging by integrating Spring Integration.
  • Java or XML based configuration.
  • All the Spring features like DI, AOP, testability, etc.
  • Vendor independence - By using Spring Batch, you get to use a framework that open source and not tied to any one vendor.

Additional advantages

Beyond the above examples of what Spring Batch brings to the table, it goes much further:

  • Scalability options - Spring Batch provides a number of scalability options that range from within a single JVM via threads (multithreaded step, local partitioning, and splits) to multi-JVM scalability (remote partitioning and remote chunking).
  • Integration with Spring Integration - Spring Integration provides a number of useful elements that allow you to build robust batch applications to handle things like error messages, poling directories for files, automatically FTPing files, etc.
  • Big data support - Through the Spring for Apache Hadoop project, there are a number of extensions to Spring Batch that allow it to work well with Hadoop. You can run Spring Batch jobs on YARN, you can execute Pig, Hive, MapReduce, etc jobs.
  • Integration with Spring XD - Spring XD provides a distributed runtime for the deployment, management, and execution of batch jobs.

I personally view batch processing as the "set it and forget it" model of programming. While it isn't sexy, batch processing is a very useful model of processing and is more useful in places than most people realize. Spring Batch provides an environment that makes developing robust batch jobs as easily as possible.

like image 172
Michael Minella Avatar answered Sep 22 '22 18:09

Michael Minella