spring-framework / org.springframework.messaging.simp.config / TaskExecutorRegistration

TaskExecutorRegistration

open class TaskExecutorRegistration

A registration class for customizing the properties of ThreadPoolTaskExecutor.

Author
Rossen Stoyanchev

Author
Juergen Hoeller

Since
4.0

Constructors

<init>

TaskExecutorRegistration()

Create a new TaskExecutorRegistration for a default ThreadPoolTaskExecutor.

TaskExecutorRegistration(taskExecutor: ThreadPoolTaskExecutor)

Create a new TaskExecutorRegistration for a given ThreadPoolTaskExecutor.

Functions

corePoolSize

open fun corePoolSize(corePoolSize: Int): TaskExecutorRegistration

Set the core pool size of the ThreadPoolExecutor.

NOTE: The core pool size is effectively the max pool size when an unbounded queueCapacity is configured (the default). This is essentially the "Unbounded queues" strategy as explained in java.util.concurrent.ThreadPoolExecutor. When this strategy is used, the maxPoolSize is ignored.

By default this is set to twice the value of Runtime#availableProcessors(). In an application where tasks do not block frequently, the number should be closer to or equal to the number of available CPUs/cores.

keepAliveSeconds

open fun keepAliveSeconds(keepAliveSeconds: Int): TaskExecutorRegistration

Set the time limit for which threads may remain idle before being terminated. If there are more than the core number of threads currently in the pool, after waiting this amount of time without processing a task, excess threads will be terminated. This overrides any value set in the constructor.

By default this is set to 60.

maxPoolSize

open fun maxPoolSize(maxPoolSize: Int): TaskExecutorRegistration

Set the max pool size of the ThreadPoolExecutor.

NOTE: When an unbounded queueCapacity is configured (the default), the max pool size is effectively ignored. See the "Unbounded queues" strategy in java.util.concurrent.ThreadPoolExecutor for more details.

By default this is set to Integer.MAX_VALUE.

queueCapacity

open fun queueCapacity(queueCapacity: Int): TaskExecutorRegistration

Set the queue capacity for the ThreadPoolExecutor.

NOTE: when an unbounded queueCapacity is configured (the default), the core pool size is effectively the max pool size. This is essentially the "Unbounded queues" strategy as explained in java.util.concurrent.ThreadPoolExecutor. When this strategy is used, the maxPoolSize is ignored.

By default this is set to Integer.MAX_VALUE.