Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document expected behavior of a method annotated with multiple @Scheduled annotations #23959

Closed
behrangsa opened this issue Nov 9, 2019 · 4 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: documentation A documentation task
Milestone

Comments

@behrangsa
Copy link

I had a look at the docs and couldn't find anything about the expected behaviour of a method being annotated by multiple @Scheduled annotations, such as:

@Scheduled(cron = "...")
@Scheduled(initialDelay = ..., fixedDelay = ...)
public void launchTheDrones() {
    // ...
}

// or

@Scheduled(fixedRate = 10_000)
@Scheduled(fixedRate = 20_000)
public void launchTheCyborgs() {
    // ...
}

// or

@Scheduled(cron = "0 * * * * MON-FRI")
@Scheduled(cron = "0 * * * * MON-TUE")
public void launchTheShuttles() {
    // ...
}

I assume this depends on the task executor in use -- some are single threaded and only run the method once at any given point in time, but what if a ThreadPoolTaskExecutor with a core pool size > 1 is used?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 9, 2019
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: documentation A documentation task labels Nov 9, 2019
@sbrannen
Copy link
Member

sbrannen commented Nov 9, 2019

Good point. The documentation can be improved in that regard.

@sbrannen sbrannen added this to the General Backlog milestone Nov 9, 2019
@sbrannen sbrannen removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 9, 2019
@rohitp27
Copy link
Contributor

@sbrannen Is this issue on the agenda for future releases? I can get on it.

@sbrannen
Copy link
Member

@sbrannen Is this issue on the agenda for future releases?

It's currently in the General Backlog, meaning that we do plan to address it at some point, but it is not currently assigned to a scheduled release.

I can get on it.

Sure, feel free to submit a PR.

@jhoeller jhoeller modified the milestones: General Backlog, 6.1.x, 6.0.12 Jul 13, 2023
@jhoeller jhoeller self-assigned this Jul 14, 2023
@jhoeller
Copy link
Contributor

I've added the following to the documentation:

@Scheduled can be used as a repeatable annotation. If several scheduled declarations are found on the same method, each of them will be processed independently, with a separate trigger firing for each of them. As a consequence, such co-located schedules may overlap and execute multiple times in parallel or in immediate succession. Please make sure that your specified cron expressions etc do not accidentally overlap.

@sbrannen sbrannen changed the title Document the expected behavior of a method annotated by multiple @Scheduled annotations Document expected behavior of a method annotated with multiple @Scheduled annotations Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: documentation A documentation task
Projects
None yet
Development

No branches or pull requests

5 participants