May 2015
Intermediate to advanced
234 pages
4h 18m
English
A step can consist of just an execution of a system command. Spring Batch provides a convenient class for this, SystemCommandTasklet.
We'll use the job defined in the Creating a job recipe.
In Spring Batch's configuration file, add a SystemCommandTasklet bean. Declare the system command to be executed (here, we used the touch Unix command to create an empty file), the directory to execute it from, and the maximum time allowed for its execution:
@Bean
public SystemCommandTasklet task1() {
SystemCommandTasklet tasklet = new SystemCommandTasklet();
tasklet.setCommand("touch test.txt");
tasklet.setWorkingDirectory("/home/merlin");
tasklet.setTimeout(5000);
return tasklet;
}The SystemCommandTasklet ...
Read now
Unlock full access