A short introduction to Spring Batch 2.0

Spring Batch provides a framework in order to develop batch processes in Java. Recently version 2.0 has been released. However it’s still hard to find good samples and resources in the web, so old-fashioned development (based on RTFM) must be performed.

The main idea is to build Jobs from sequential steps. Each step can be a single task or an input/output process. Following Spring philosophy, configuration can be done using XML.

At least, two XML files must be defined:

  • Launch context. Job launcher, datasources and other usual Spring resources.
  • Job definition. Jobs and Spring beans implementing tasks.

A batch can be launched from command line using CommandLineJobLauncher class provided by the framework. The argument “job” indicates job name and some other job parameters can be added using “key=value” pattern.

java CommandLineJobRunner job-definition.xml job date=2008/01/01

Below a basic sample  (read web server log file and insert processed lines to database) is exposed.

Launch context (job-definition.xml)


  <!-- In memory JOB Management -->





  <!-- Datasource -->




Job definition (module-context.xml)






Deja un comentario

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s