Please explain how does @Async annotation works with @Scheduled tasks. For example, i have class:
@Configuration
@EnableScheduling
@ConditionalOnProperty(name = "scheduler.enabled", matchIfMissing = true)
@RequiredArgsConstructor
@EnableAsync
public class Scheduler {
private final ReportService reportService;
@Scheduled(cron = "${scheduler.create-reports.cron}")
@Async
public void createDailyReports() {
// TODO: Make request to team-service to find all students id's. Then create new empty reports
List<Long> studentIdList = new ArrayList<>();
reportService.createEmptyDailyReports(studentIdList);
}
}
Is it necessary to annotate inner reportService.createEmptyDailyReports
method with @Async to process whole createDailyReports()
in async or @Async on createDailyReports()
is enough?
In my mind one @Async is enough. Thanks for explanation