38

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?

2
  • 4
    You don't get restartability, monitoring and whole batch infrastructure in java. Ofcourse you can do everything with plain java but would you ?
    – M. Deinum
    Nov 14, 2014 at 12:37
  • 8
    Why on earth close the question? @M.Deinum Of course it's opinion-based, but I want to hear people's opinions to make up my own mind! We share our experience after all. Did this question bother you or what... Feb 2, 2018 at 20:04

1 Answer 1

75

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.

2
  • 5
    Spring Batch Admin - Even though not part of core batch framework. The batch admin application is quite useful and provided a basic UI which not only provides a View into your Jobs but also allows you to perform basic operations like, start, stop, restart. It is also possible to enhance this application as much as you like.
    – Prakash
    Jan 12, 2016 at 16:02
  • 1
    Spring Batch Admin has been killed in favor of DataFlow. Latter can't be used outside of "cloud" stuff. So there is no any pre-built dashboard for Spring Batch for now.
    – gavenkoa
    Jul 9, 2018 at 10:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.