ExecutorConfigurationSupport
API refinement to control internal executor shutdown
#24497
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Currently,
ExecutorConfigurationSupport#shutdown()
encapsulate multiple scenarios for shutting down internalExecutorService
.The single method
shutdown()
performsshutdown()/shutdownNow()
(non-blocking) andawaitTermination()
(blocking) based on its property.I am writing a graceful shutdown logic for task executor/scheduler.
The logic for graceful shutdown is to retrieve all task executor/schedulers and apply:
shutdown()
to not accept anymore tasksWith current available API, I need to do following:
Since this calls
shutdown()
twice with different parameter in order to achieveshutdown()
andawaitTermination()
for underlying executor, it is not so intuitive. Also requires to know the detail about whatExecutorConfigurationSupport#shutdown()
does.Another workaround is to retrieve internal
ExecutorService
and callshutdown()
andawaitTermination()
.I think it would be nice to have some API refinement for task executor/scheduler to easily control underlying
ExecutorService
.Simple solution is to to add a getter to
ExecutorConfigurationSupport
to expose internalExecutorService
. This way, in addition to existingshutdown()
, if user needs to do more fine control on shutdown, getter can expose theExecutorService
.Another way is to provide blocking(
awaitTermination
) and non-blocking(shutdown/shutdownNow
) methods onExecutorConfigurationSupport
instead or in addition to the currentshutdown()
method.The text was updated successfully, but these errors were encountered: