Reputation: 1708
I have this simple example of Spring Scheduler:
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class AppScheduler {
@Scheduled(fixedRate = 10000)
public void myScheduler() {
System.out.println("Test print");
}
}
Is there a way to trigger execution in the current moment let's say from web page?
Upvotes: 0
Views: 84
Reputation: 18235
Just make a dump controller to call myScheduler
method:
@Controller
public class DumpController {
@Autowired
private AppScheduler scheduler;
@RequestMapping("/ping")
public void ping() {
scheduler.myScheduler();
}
}
Upvotes: 1