Class ThreadPoolProfile
java.lang.Object
org.apache.camel.spi.ThreadPoolProfile
- All Implemented Interfaces:
Serializable, Cloneable
A named, reusable configuration template for
ThreadPoolExecutor settings managed by the
ExecutorServiceManager.
Rather than hard-coding pool parameters at each call site, Camel components and EIPs declare a profile id (or use the
default profile). The ExecutorServiceManager looks up the profile and passes it to the
ThreadPoolFactory to create the actual pool. The default profile provides baseline values (typically
poolSize=10, maxPoolSize=20, keepAlive=60s, maxQueueSize=1000) that are applied whenever a parameter is not
explicitly set on a custom profile.
A profile is also the vehicle for configuring the rejected-execution policy via setRejectedPolicy(ThreadPoolRejectedPolicy), which
determines what happens when the work queue is full and all threads are busy.
See Threading Model in the Camel user manual.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new thread pool profile, with no id set.Creates a new thread pool profile -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDefaults(@Nullable ThreadPoolProfile defaultProfile) Overwrites each attribute that is null with the attribute from defaultProfileclone()@Nullable BooleanGets whether to allow core threads to timeout@Nullable StringgetId()Gets the id of this profile@Nullable LongGets the keep alive time for inactive threads@Nullable IntegerGets the maximum pool size@Nullable IntegerGets the maximum number of tasks in the work queue.@Nullable IntegerGets the core pool size (threads to keep minimum in pool)@Nullable RejectedExecutionHandlerGets the handler for tasks which cannot be executed by the thread pool.@Nullable org.apache.camel.util.concurrent.ThreadPoolRejectedPolicyGets the policy for tasks which cannot be executed by the thread pool.@Nullable TimeUnitGets the time unit used for keep alive timeWhether this profile is the default profile (there can only be one).booleanisEmpty()voidsetAllowCoreThreadTimeOut(@Nullable Boolean allowCoreThreadTimeOut) Sets whether to allow core threads to timeoutvoidsetDefaultProfile(@Nullable Boolean defaultProfile) Sets whether this profile is the default profile (there can only be one).voidSets the id of this profilevoidsetKeepAliveTime(@Nullable Long keepAliveTime) Sets the keep alive time for inactive threadsvoidsetMaxPoolSize(@Nullable Integer maxPoolSize) Sets the maximum pool sizevoidsetMaxQueueSize(@Nullable Integer maxQueueSize) Sets the maximum number of tasks in the work queue.voidsetPoolSize(@Nullable Integer poolSize) Sets the core pool size (threads to keep minimum in pool)voidsetRejectedPolicy(@Nullable org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy rejectedPolicy) Sets the handler for tasks which cannot be executed by the thread pool.voidsetTimeUnit(@Nullable TimeUnit timeUnit) Sets the time unit used for keep alive timetoString()
-
Constructor Details
-
ThreadPoolProfile
public ThreadPoolProfile()Creates a new thread pool profile, with no id set. -
ThreadPoolProfile
Creates a new thread pool profile- Parameters:
id- id of the profile
-
-
Method Details
-
getId
-
setId
-
isDefaultProfile
Whether this profile is the default profile (there can only be one).- Returns:
- true if its the default profile, false otherwise
-
setDefaultProfile
Sets whether this profile is the default profile (there can only be one).- Parameters:
defaultProfile- the option
-
getPoolSize
Gets the core pool size (threads to keep minimum in pool)- Returns:
- the pool size
-
setPoolSize
Sets the core pool size (threads to keep minimum in pool)- Parameters:
poolSize- the pool size
-
getMaxPoolSize
-
setMaxPoolSize
Sets the maximum pool size- Parameters:
maxPoolSize- the max pool size
-
getKeepAliveTime
Gets the keep alive time for inactive threads- Returns:
- the keep alive time
-
setKeepAliveTime
Sets the keep alive time for inactive threads- Parameters:
keepAliveTime- the keep alive time
-
getTimeUnit
Gets the time unit used for keep alive time- Returns:
- the time unit
-
setTimeUnit
Sets the time unit used for keep alive time- Parameters:
timeUnit- the time unit
-
getMaxQueueSize
Gets the maximum number of tasks in the work queue. Use -1 or Integer.MAX_VALUE for an unbounded queue- Returns:
- the max queue size
-
setMaxQueueSize
Sets the maximum number of tasks in the work queue. Use -1 or Integer.MAX_VALUE for an unbounded queue- Parameters:
maxQueueSize- the max queue size
-
getAllowCoreThreadTimeOut
Gets whether to allow core threads to timeout- Returns:
- the allow core threads to timeout
-
setAllowCoreThreadTimeOut
Sets whether to allow core threads to timeout- Parameters:
allowCoreThreadTimeOut- true to allow timeout
-
getRejectedPolicy
public @Nullable org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy getRejectedPolicy()Gets the policy for tasks which cannot be executed by the thread pool.- Returns:
- the policy for the handler
-
getRejectedExecutionHandler
Gets the handler for tasks which cannot be executed by the thread pool.- Returns:
- the handler, or null if none defined
-
setRejectedPolicy
public void setRejectedPolicy(@Nullable org.apache.camel.util.concurrent.ThreadPoolRejectedPolicy rejectedPolicy) Sets the handler for tasks which cannot be executed by the thread pool.- Parameters:
rejectedPolicy- the policy for the handler
-
addDefaults
Overwrites each attribute that is null with the attribute from defaultProfile- Parameters:
defaultProfile- profile with default values
-
isEmpty
public boolean isEmpty() -
clone
-
toString
-