Spring Cloud Data Flow can also be used to create and schedule batch applications. For the last decade, Spring Batch has been the framework of choice to develop batch applications. Spring Cloud Task extends this and enables execution of batch programs on the Cloud.
Let's use Spring Initializr (https://start.spring.io) to set up the application. Provide the details listed here and click on Generate Project:
- Group: com.mastering.spring.cloud.data.flow
- Artifact: simple-logging-task
- Dependencies: Cloud Task
Update the SimpleLoggingTaskApplication class with the following code:
@SpringBootApplication
@EnableTask
public class SimpleLoggingTaskApplication {
@Bean
public CommandLineRunner commandLineRunner() {
return strings -> System.out.println(
"Task execution :" + new SimpleDateFormat().format(new Date()));
}
public static void main(String[] args...