Class TaskExecutorStatusProvider

java.lang.Object
com.github.jpmsilva.jsystemd.spring.TaskExecutorStatusProvider
All Implemented Interfaces:
StatusProvider, SmartInitializingSingleton

public class TaskExecutorStatusProvider extends Object implements StatusProvider, SmartInitializingSingleton
Implementation of StatusProvider that provides information regarding the thread pools of the task executors and schedulers of the application, such as the ones Spring Boot sets up for @Async and @Scheduled methods, each reported by an ExecutorStatusProvider named after its bean, such as applicationTaskExecutor: 2/8 threads, 5 queued, taskScheduler: 1/1 threads, 3 scheduled.

The task executors are the ThreadPoolTaskExecutor and ThreadPoolTaskScheduler beans, found once all singleton beans are created, so that lazy ones are not created. Those that run tasks on virtual threads, as Spring Boot sets them up with spring.threads.virtual.enabled=true, have no thread pool, and are left out.

Author:
Joao Silva
  • Constructor Details

    • TaskExecutorStatusProvider

      public TaskExecutorStatusProvider(ConfigurableListableBeanFactory beanFactory)
      Creates a new instance that finds the task executors in the given bean factory.
      Parameters:
      beanFactory - the bean factory to find the task executors in
  • Method Details

    • afterSingletonsInstantiated

      public void afterSingletonsInstantiated()
      Finds the task executors among the singleton beans that are already created.
      Specified by:
      afterSingletonsInstantiated in interface SmartInitializingSingleton
    • status

      public String status()
      Description copied from interface: StatusProvider
      Exposes status information to send to systemd.
      Specified by:
      status in interface StatusProvider
      Returns:
      the string message to add to the service status