How to integrate spring batch + spring boot + quartz

2

Good morning. Currently in my project I am using spring boot and spring batch. Creating the batch was easy, even running it when starting the application with tombe embebed from the spring boot however, I need to run this batch from time to time. The solution that comes to mind is to use quartz to execute this batch, but I'm not succeeding with this integration .. Can anyone help me with some example?

    
asked by anonymous 27.01.2017 / 14:21

1 answer

1

Use the Spring% wrapper.

Create the class to run the scheduled task:

@Service
public class AgendadorService {

    @Scheduled(fixedRate = 5000)
    public void executaBatch() {
        //Implementar chamada para o batch
    }

}

In this case, the task runs every 5 seconds, but there are other scheduling changes, depending on documentation .

To enable the scheduling feature in Spring Boot, you need to add the @Scheduled annotation as follows:

@SpringBootApplication
@EnableScheduling
public class Application {

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class);
    }
}
    
10.02.2017 / 19:25