Class AxonTaskJanitor
java.lang.Object
org.axonframework.messaging.core.timeout.AxonTaskJanitor
Utility constructing a
ScheduledExecutorService and providing Logger instances for the
AxonTimeLimitedTask.
To ensure a unique executor is used throughout, the executorComponent() should be registered with an
applications Configuration just once under the EXECUTOR_COMPONENT_NAME. Doing so on top level
ensures (1) that there is a single instance throughout and (2) that it's lifecycle is tied to the application's
lifecycle.
- Since:
- 4.11.0
- Author:
- Mitchell Herrijgers, Steven van Beelen
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name under which theConfiguration-scopedScheduledExecutorService, defined byexecutorComponent(), is known in theConfiguration.static final org.slf4j.LoggerUnique instance of theLoggerfor theAxonTimeLimitedTaskto log warnings and errors. -
Method Summary
Modifier and TypeMethodDescriptionprotected static ScheduledThreadPoolExecutorCreates theScheduledExecutorServiceused for scheduling the interrupting task.Creates aComponentDefinitionfor aScheduledExecutorService, namedEXECUTOR_COMPONENT_NAME, scoped to whicheverConfigurationit is registered with (for example throughComponentRegistry.registerIfNotPresent(ComponentDefinition)).
-
Field Details
-
EXECUTOR_COMPONENT_NAME
The name under which theConfiguration-scopedScheduledExecutorService, defined byexecutorComponent(), is known in theConfiguration.- See Also:
-
LOGGER
public static final org.slf4j.Logger LOGGERUnique instance of theLoggerfor theAxonTimeLimitedTaskto log warnings and errors.
-
-
Method Details
-
executorComponent
Creates aComponentDefinitionfor aScheduledExecutorService, namedEXECUTOR_COMPONENT_NAME, scoped to whicheverConfigurationit is registered with (for example throughComponentRegistry.registerIfNotPresent(ComponentDefinition)).The defined executor is created lazily, on first use, and is shut down automatically when the owning
Configurationshuts down. Since the executor is scoped to a singleConfiguration, shutting thatConfigurationdown can never affect timeout enforcement in anotherConfigurationsharing the same JVM.- Returns:
- a
ComponentDefinitionfor aConfiguration-scopedScheduledExecutorService
-
createExecutor
Creates theScheduledExecutorServiceused for scheduling the interrupting task.It only has one thread as the load is very low. Cancelling the tasks will clean it up to reduce memory pressure.
- Returns:
- the
ScheduledExecutorServiceused for scheduling the interrupting task
-