Using Grails to build a simple batch system

Inspired by the discussion on ‘How would you launch a Quartz job from a script?’ and basing on the post about ‘Tiny GroovyServ’, I decided to write a simple batch system using Grails and quartz, spring-security-core and batch-launcher plugins.

The batch-launcher has been choosen because, in the company where I work, there are segregated environments for online (web) applications and batch applications. So in the exclusive environment for batch applications there isn’t Tomcat, WebLogic or any Web Container or Application Server. In this context, batch applications are responsible for all massive and asynchronous processing, especially when it is required to integrate two or more systems.

Basically I created an application made by services and scheduled tasks, whose synchronous or asynchronous invocation can be done through an SSH client. The step-by-step test:

  1. Download the file (its size is about 25 Mbytes and it contains all dependencies needed to run the application)
  2. Unzip the file in a directory
  3. Start the application (the only prerequisite for this step it is to have a installed JRE and make java available in the PATH)
  4. [daniel@techdm simple_batch_system-0.1]$ ./



  5. Start the execution of services or scheduled tasks logged in as admin0 (password is admin):

    ssh -p 8123 admin0@localhost task1Job,task3Service

Some important notes:

  • For cases where there is no segregation of online (web) and batch environments, a similar approach can be used for developing regular (web) Grails applications. The source code written for handling ssh commands, can be found here;
  • The plugin spring-security-core is optional and it was used only to create a known domain model of users and profiles;
  • The mechanism of public and private keys can be adopted as an alternative authentication. This combined with a ssh-agent would eliminate the need of password exchanging, without reducing the security of the solution;
  • It is possible to develop an interactive SSH session for command execution;
  • During any development using batch-launcher, the essential commands are ‘grails batch-run-app’, ‘grails interactive’ (combined with ‘batch-reload-app’) and ‘grails batch-war’.

Project on gitbub.
Download the source code.

3 Responses to Using Grails to build a simple batch system

  1. Excelente post!

    Para agendamento em Grails você pode utilizar o Spring 3 @Scheduled ao invés de Quartz.

    Algo que você pode fazer pra melhorar ainda mais o desempenho é utilizar GPars, caso o processamento em lote possa ser paralelizado.

    A propósito, para a arquitetura em lote, você tentou avaliar o uso de Spring Batch?

Leave a Reply

Your email address will not be published. Required fields are marked *


three + 8 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>