How can I get started with Spring Batch? [closed]

Solution 1:

A few pointers:

  • Spring Batch HelloWorld
  • Spring Batch "Hello World" 1
  • Spring Batch "Hello World" 2
  • A first look at Spring Batch (via archive.org)
  • A first look at Spring Batch, part 2 (via archive.org)
  • Spring Batch : Hello World!

Solution 2:

I agree that the user guide is very confusing (compared to the Spring Core user guide at any rate). It doesn't adequately address some very important gotchas that you will run up against in any moderately complex batch scenario.

Important things that you should drill down into as a new starter, and decide your requirements for are,

  • configuration of exceptions (when to skip, when to fail, when to retry)
  • use of execution context to maintain state (eg when to use step execution context vs job execution context).
  • general maintenance of state (use the step scope, especially for input parameters)

It is worth persevering however. Batch programming is very different to other server side styles and greatly benefits from the usual Spring "pattern abstraction" approach.

Solution 3:

Before you jump on the Spring Batch wagon, you may want to read what SO's own cletus has to say about its shortcomings:

http://www.cforcoding.com/2009/07/spring-batch-or-how-not-to-design-api.html.

I recently evaluated Spring Batch, and quickly rejected it once I realized that it added nothing to my project aside from bloat and overhead. Spring Batch may eventually become an OK product (much like EJBs got it right this time around), but at the moment it looks suspiciously like a solution in search of a problem.

Solution 4:

I recently gave Spring Batch a real try. I'll say that in my implementation, I used an in-memory repository (because restarts and retries were not a priority in my project's circumstance), but I can appreciate what Richard says about the JobRepository: you basically have to dig deep to find the database schema.

For Spring Batch 2.1, they do provide some documentation on the repository: http://static.springsource.org/spring-batch/reference/html/metaDataSchema.html, including discussions about how to deal with database-specific implementations. The DDL for creating the tables are located in the core Spring Batch JAR file:

spring-batch-core-2.1.0.RELEASE.jar:/org/springframework/batch/core/*.sql

Scripts are present for DB2, Derby, H2, HSQLDB, MySQL, Oracle 10g, PostgreSQL, MS SQL, and Sybase.

Solution 5:

In this tutorial, we will create a simple Spring Batch application to demonstrate how to process a series of jobs where the primary purpose is to import a lists of comma-delimited and fixed-length records. In addition, we will add a web interface using Spring MVC to teach how to trigger jobs manually, and so that we can visually inspect the imported records. In the data layer, we will use JPA, Hibernate, and MySQL.

  1. http://krams915.blogspot.jp/2012/02/spring-batch-tutorial-part-1.html
  2. http://krams915.blogspot.jp/2012/02/spring-batch-tutorial-part-2.html
  3. http://krams915.blogspot.jp/2012/02/spring-batch-tutorial-part-3.html
  4. http://krams915.blogspot.jp/2012/02/spring-batch-tutorial-part-4.html