Code: Select all
@Service
public class SchedulerA {
private SomeService service;
@Scheduled(fixedDelay = 2 * 60 * 1000)
public void taskA() {
service.methodA();
}
}
Code: Select all
@Service
public class SchedulerB {
private SomeService service;
@Scheduled(fixedDelay = 2 * 60 * 1000, initialDelay = 1 * 1000)
public void taskA() {
List> methodB() {
List tasks = repository.findAllByStatus("readyForTaskB");
return tasks.stream()
.map(task -> executorService.submit(() -> runTaskB(task)))
.collect(Collectors.toList());
}
private void runTaskA(Task task){
//do something
}
private void runTaskB(Task task) {
//do something
}
}