Search code examples
springgrailsspring-batchgrails-plugin

Spring batch split flow supported in the Grails plugin?


I am using Spring batch plugin for Grails (spring-batch-1.0.RC2). So far is working properly but I want to split the flow to execute ... is that supported? This is the code I am trying to execute... but the result is Step1, Step2, Step3, Step 4.

beans {
  xmlns batch:"http://www.springframework.org/schema/batch"

  jobLauncher(org.springframework.batch.core.launch.support.SimpleJobLauncher){
     jobRepository = ref("jobRepository")
     taskExecutor = bean(org.springframework.core.task.SimpleAsyncTaskExecutor)
     taskExecutorParallel = bean(org.springframework.core.task.SimpleAsyncTaskExecutor)
  }

  batch.job(id: 'endOfDayJob') {
     batch.step(id: 'logStart', next:'createContext') {
        batch.tasklet(ref: 'printStartMessage')
     }

  batch.step(id: 'createContext', next:'split1') {
    batch.tasklet(ref: 'context')
  }

  batch.split(id: 'split1',taskexecutor:'taskExecutorParallel', next:'logFinish'  ) {
    batch.flow{ 

       batch.step(id:'step1Id', next:'step2Id'){
            batch.tasklet(ref: 'step1')
        }           
        batch.step(id: 'step2Id') {
            batch.tasklet(ref: 'step2')
        }
    }
    batch.flow{
        batch.step(id:'step3Id', next:'step4Id'){
            batch.tasklet(ref: 'step3')
        } 
        batch.step(id: 'step4Id') {
            batch.tasklet(ref: 'step4')
        }
    }
  }

  batch.step(id: 'logFinish') {
    batch.tasklet(ref: 'printEndMessage')
  }
}

Thanks!


Solution

  • I got it... it's supported... I had a mistake in this line:

    batch.split(id: 'split1','task-executor':'taskExecutorParallel', next:'logFinish'  ) {