[BAEL-3289] Add missing code snippets from the Spring Scheduled article
All the samples still existed with some slight variation, I updated where applicable Main thing is that the link in the article has to be corrected
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
### Relevant articles:
|
||||
- [A Guide to the Spring Task Scheduler](http://www.baeldung.com/spring-task-scheduler)
|
||||
- [The @Scheduled Annotation in Spring](https://www.baeldung.com/spring-scheduled-tasks)
|
||||
- [Guide to Spring Retry](http://www.baeldung.com/spring-retry)
|
||||
- [How To Do @Async in Spring](http://www.baeldung.com/spring-async)
|
||||
|
||||
|
||||
@@ -31,9 +31,10 @@ public class ScheduledAnnotationExample {
|
||||
System.out.println("Fixed rate task - " + System.currentTimeMillis() / 1000);
|
||||
}
|
||||
|
||||
@Scheduled(fixedDelay = 1000, initialDelay = 100)
|
||||
@Scheduled(fixedDelay = 1000, initialDelay = 1000)
|
||||
public void scheduleFixedRateWithInitialDelayTask() {
|
||||
System.out.println("Fixed delay task with one second initial delay - " + System.currentTimeMillis() / 1000);
|
||||
long now = System.currentTimeMillis() / 1000;
|
||||
System.out.println("Fixed rate task with one second initial delay - " + now);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,7 +42,8 @@ public class ScheduledAnnotationExample {
|
||||
*/
|
||||
@Scheduled(cron = "0 15 10 15 * ?")
|
||||
public void scheduleTaskUsingCronExpression() {
|
||||
System.out.println("schedule tasks using cron expressions - " + System.currentTimeMillis() / 1000);
|
||||
long now = System.currentTimeMillis() / 1000;
|
||||
System.out.println("schedule tasks using cron jobs - " + now);
|
||||
}
|
||||
|
||||
@Scheduled(cron = "${cron.expression}")
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
<bean id="myscheduler" class="org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler"/>
|
||||
|
||||
<!-- Configure the fixedDealy, fixedRate or cron based schduled tasks -->
|
||||
<!-- Configure the fixedDealy, fixedRate or cron based scheduled tasks -->
|
||||
<bean id="schedulingWithXmlConfig" class="org.baeldung.scheduling.SchedulingWithXmlConfig"/>
|
||||
|
||||
<task:scheduled-tasks scheduler="myScheduler">
|
||||
|
||||
Reference in New Issue
Block a user