ThreadpoolSwiftlet

 
 

Online Documentation    Property Configuration    ThreadpoolSwiftlet

 
 

[Swiftlet Name]     [Threadpool Concept]     [Pool Names]     [Thread Names]     [Minimum Threads]     [Maximum Threads]     [Idle Timeout]     [Priority]     [Cleanup Interval]    
[Document Index]

 
     
 
  Swiftlet Name

The Swiftlet name of the ThreadpoolSwiftlet is sys$threadpool.

Threadpool Concept

The ThreadpoolSwiftlet provides threadpool services for the whole SwiftMQ server. The idea behind it is to have a central point for controlling and monitoring thread resources. So the ThreadpoolSwiftlet is likely what a process management is for an OS.

Every Swiftlet that wants to start a thread creates a Runnable and dispatches it to the ThreadpoolSwiftlet under a specific name. The ThreadpoolSwiftlet makes a lookup for the threadname and fetches the appropriate threadpool, picks up an idling thread, or creates a new thread if none is idling in that pool, and starts the thread with this Runnable. If the Runnable is terminated, the thread marks itself as idling. Idling threads are deleted if their time-to-live is exceeded and the minimum threads in its pool is not reached. This task performs a cleanup thread in the threadpool itself, which travels over the pools in specific intervals.

The definition of threadpools takes place in the ThreadpoolSwiftlet configuration. Each pool can be defined as:

Thread name

A list of SQL-Like predicates which define the threads that are to run into this pool. The thread names for every Swiftlet that dispatches to the ThreadpoolSwiftlet are defined in the section Thread Names for Threadpool dispatch in the Swiftlet configurations. By collecting thread names under functional aspects to threadpools, one can create a functional unit of control. For example, one can create a pool which contains all inbound listeners or a pool with all JMS threads and so on.

Minimum threads

Specifies a minimum of idling threads a pool should contain. At Swiftlet startup this number of threads is created but not started. They are idle until they are needed. Clean up of idling threads only occurs if there are more idling threads than the specified minimum. This property is useful on platforms with high thread creation costs.

Maximum threads

Specifies a maximum number of threads for this pool. If a Swiftlet dispatches a Runnable to a pool and the maximum number is already reached, an exception occurs. Setting a maximum enables resource limitations. For example, putting all message forwarders of the RoutingSwiftlet in one pool and setting the maximum to 10 limits the route destinations a router can handle to 10.

Priority

Specifies the priority that is assigned to each thread running in this pool. Per default, a threadpool has a standard priority. By changing the priority one can give pools more or less chances to run their threads. For example, to give the JMSSwiftlet a higher priority than the RoutingSwiftlet, create 2 pools, one with JMS thread names, one with routing thread names, and give the JMS pool a higher priority than the routing pool.

Idle Timeout

Specifies how long a thread should idle before it is cleaned up by the cleanup thread. This parameter is useful if there is a high interval of re-use, because it is better to re-use an existing thread instead of creating a new one.

The ThreadpoolSwiftlets creates two predefined threadpools on startup:

system

Contains per default the clean up thread of the ThreadpoolSwiftlet.

default

A pool in which every thread runs if no pool can be assigned to the thread name. If no pools are defined, all threads run into the default pool.

Pool Names

Optional property that specifies a list of pool names. For every defined pool name, sub-properties can be defined as described in the following sections.

Property definition:


 swiftlet.sys$threadpool.pools.names=<name 1>,<name 2>,..,<name n>

Example:


 swiftlet.sys$threadpool.pools.names=jms,jndi,routing,topic,timer

Thread Names

Specifies for each pool which thread names are assigned to this pool. If a thread name is not assigned to any pool, it runs into the default pool.

The thread names are in SQL-Like predicate format. For example, it is possible to specify sys$jms:% to assign all JMS threads.

Property definition:


 swiftlet.sys$threadpool.pools.<name>.threads.names=<name 1>,<name 2>,..,<name n>

Example:


 swiftlet.sys$threadpool.pools.jmsandjndi.threads.names=sys$jms:%,sys$jndi:%

Minimum Threads

Optional property that specifies the minimum of idling threads each pool should contain. This number of threads is created at startup and will never be cleaned up.

The default value for this property is 0.

Property definition:


 swiftlet.sys$threadpool.pools.<name>.thread.min=<integer>

Example:


 swiftlet.sys$threadpool.pools.jms.thread.min=20

Maximum Threads

Optional property that specifies the maximum threads each pool should contain. Setting a maximum is equal to resource limitations.

The default value for this property is -1 (unlimited).

Property definition:


 swiftlet.sys$threadpool.pools.<name>.thread.max=<integer>

Example:


 swiftlet.sys$threadpool.pools.routingmsgfwd.thread.max=10

Idle Timeout

Optional property that specifies the timeout in milliseconds of idling threads in this pool. After this time is reached, a thread is cleaned up by the cleanup thread. A value of -1 states that this pool will never time out.

The default value for this property is 120000 (2 minutes).

Property definition:


 swiftlet.sys$threadpool.pools.<name>.idletimeout=<long>

Example:


 swiftlet.sys$threadpool.pools.jms.idletimeout=60000

Priority

Optional property that specifies the priority that is assigned to each thread running in this pool. The value has to be between 0 (lowest priority) and 10 (highest priority).

The default value for this property is 5 (Thread.NORM_PRIORITY).

Property definition:


 swiftlet.sys$threadpool.pools.<name>.priority=<integer>

Example:


 swiftlet.sys$threadpool.pools.jms.priority=6

Cleanup Interval

Optional property that specifies the cleanup interval in milliseconds for the cleanup thread in the pool, and deletes idling threads for which the time-to-live has expired.

The default value for this property is 120000 (2 minutes).

Property definition:


 swiftlet.sys$threadpool.cleanupinterval=<long>

Example:


 swiftlet.sys$threadpool.cleanupinterval=360000

 
 
     
 

[Swiftlet Name]     [Threadpool Concept]     [Pool Names]     [Thread Names]     [Minimum Threads]     [Maximum Threads]     [Idle Timeout]     [Priority]     [Cleanup Interval]    
[Document Index]

 
 

Online Documentation    Property Configuration    ThreadpoolSwiftlet

 
 

 Copyright © 2000, IIT GmbH, Bremen/Germany. All rights reserved.
SwiftMQ and Swiftlet are registered trademarks of IIT GmbH.
All other product names mentioned herein are trademarks of their respective owners.