[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:
Martin van Wingerden
2019-10-23 11:33:00 +02:00
parent bcf119bf1a
commit 546acf842f
3 changed files with 7 additions and 4 deletions

View File

@@ -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)

View File

@@ -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}")

View File

@@ -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">