Skip to content

Commit e303916

Browse files
committed
Document repeatable annotation semantics for @scheduled
Closes gh-23959
1 parent 75f5dac commit e303916

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

framework-docs/modules/ROOT/pages/integration/scheduling.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,12 @@ Notice that the methods to be scheduled must have void returns and must not acce
380380
arguments. If the method needs to interact with other objects from the application
381381
context, those would typically have been provided through dependency injection.
382382

383+
`@Scheduled` can be used as a repeatable annotation. If several scheduled declarations
384+
are found on the same method, each of them will be processed independently, with a
385+
separate trigger firing for each of them. As a consequence, such co-located schedules
386+
may overlap and execute multiple times in parallel or in immediate succession.
387+
Please make sure that your specified cron expressions etc do not accidentally overlap.
388+
383389
[NOTE]
384390
====
385391
As of Spring Framework 4.3, `@Scheduled` methods are supported on beans of any scope.

spring-context/src/main/java/org/springframework/scheduling/annotation/Scheduled.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929

3030
/**
3131
* Annotation that marks a method to be scheduled. Exactly one of the
32-
* {@link #cron}, {@link #fixedDelay}, or {@link #fixedRate} attributes must be
33-
* specified.
32+
* {@link #cron}, {@link #fixedDelay}, or {@link #fixedRate} attributes
33+
* must be specified.
3434
*
3535
* <p>The annotated method must expect no arguments. It will typically have
3636
* a {@code void} return type; if not, the returned value will be ignored
@@ -42,7 +42,10 @@
4242
* XML element or {@link EnableScheduling @EnableScheduling} annotation.
4343
*
4444
* <p>This annotation can be used as a <em>{@linkplain Repeatable repeatable}</em>
45-
* annotation.
45+
* annotation. If several scheduled declarations are found on the same method,
46+
* each of them will be processed independently, with a separate trigger firing
47+
* for each of them. As a consequence, such co-located schedules may overlap
48+
* and execute multiple times in parallel or in immediate succession.
4649
*
4750
* <p>This annotation may be used as a <em>meta-annotation</em> to create custom
4851
* <em>composed annotations</em> with attribute overrides.

0 commit comments

Comments
 (0)