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
Add a way to set executeExistingDelayedTasksAfterShutdown from ThreadPoolTaskScheduler #26719
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Comments
spring-projects-issues
added
the
status: waiting-for-triage
An issue we've not yet triaged or decided on
label
Mar 24, 2021
jhoeller
added
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
and removed
status: waiting-for-triage
An issue we've not yet triaged or decided on
labels
Mar 24, 2021
Aelykto
pushed a commit
to Aelykto/spring-framework
that referenced
this issue
Apr 15, 2021
… property. This closes an existing issue: spring-projects#26719
Aelykto
pushed a commit
to Aelykto/spring-framework
that referenced
this issue
Apr 15, 2021
…Shutdown property. This closes an existing issue: spring-projects#26719" This reverts commit f179d53
Aelykto
pushed a commit
to Aelykto/spring-framework
that referenced
this issue
Apr 15, 2021
…nd ContinueExistingPeriodicTasksAfterShutdown policies. This closes an existing issue: spring-projects#26719"
Aelykto
pushed a commit
to Aelykto/spring-framework
that referenced
this issue
Apr 16, 2021
…nd ContinueExistingPeriodicTasksAfterShutdown policies. This closes an existing issue: spring-projects#26719"
I ended up introducing the remaining policy setter methods from |
Zoran0104
pushed a commit
to Zoran0104/spring-framework
that referenced
this issue
Aug 20, 2021
lxbzmy
pushed a commit
to lxbzmy/spring-framework
that referenced
this issue
Mar 26, 2022
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: enhancement
A general enhancement
Observed behaviour
ThreadPoolTaskScheduler
is used for methods annotated with@Scheduled
.In the example of a method which is to be run at a specific time e.g.
@Scheduled( cron = "0 0 2 * * *" )
(run at 2 a.m.), theScheduledThreadPoolExecutor
withinThreadPoolTaskScheduler
knows that it must execute this at the future time.However, when I call
threadPoolTaskScheduler.shutdown()
the shutdown is being blocked until the queued task has been exectued. In the above example this would be, 2 a.m. + the time it takes to execute the task. Note that this behaviour only happens when I have configured a long enough termination period withthreadPoolTaskScheduler.setAwaitTerminationSeconds
.One other point. I know the
ThreadPoolTaskScheduler
will get automatically shutdown when the application shuts down, but I am doing it manually for other reasons which I won't go into in this issue.In summary:
ThreadPoolTaskScheduler
has a long terimation period (setAwaitTerminationSeconds
)threadPoolTaskScheduler.shutdown()
My requirement here is that the
ThreadPoolTaskScheduler
should shut down faster by only waiting for those tasks which are currently being processed. Tasks which are scheduled for a future time will not be executed.Current workaround
I found a method on
ScheduledThreadPoolExecutor
namedsetExecuteExistingDelayedTasksAfterShutdownPolicy
which seems to do what I need.When I set this value to
false
by configuring a customThreadPoolTaskScheduler
I observe the desired behaviour.Suggested improvement
Could we configure this more easily using a property on the
ThreadPoolTaskScheduler
? In theThreadPoolTaskScheduler
methodinitializeExecutor
it already does similar configurations e.g. for theremoveOnCancelPolicy
If being able to set this configuration would be valuable for this framework, then maybe this would be a suitable place to put it?
The end result of how to use the new functionality might look like this:
The text was updated successfully, but these errors were encountered: