JBoss.orgCommunity Documentation

Chapter 3. Pooling

3.1. Strategy
3.2. Transaction stickness
3.3. Workaround for Oracle
3.4. Pool Access
3.5. Pool Filling
3.6. Idle Connections
3.7. Dead connections
3.7.1. Valid connection checking
3.7.2. Errors during SQL queries
3.7.3. Changing/Closing/Flushing the pool
3.7.4. Other pooling

JBossJCA uses a ManagedConnectionPool to perform the pooling. The ManagedConnectionPool is made up of subpools depending upon the strategy chosen and other pooling parameters.

xml

mbean

Internal Name

Description

ByNothing

OnePool

A single pool of equivalent connections

<application-managed-security/>

ByApplication

PoolByCRI

Use the connection properties from allocateConnection()

<security-domain/>

ByContainer

PoolBySubject

A pool per Subject, e.g. preconfigured or EJB/Web login subjects

<security-domain-and-applicaton/>

ByContainerAndApplicaton

PoolBySubjectAndCri

A per Subject and connection property combination

Note

The xml names imply this is just about security. This is misleading.

For <security-domain-and-application/> the Subject always overrides any user/password from createConnection(user, password) in the CRI:

(
ConnectionRequestInfo
) 

You can force the same connection from a (sub-)pool to get reused throughout a transaction with the <track-connection-by-tx/> flag

Oracle does not like XA connections getting used both inside and outside a JTA transaction. To workaround the problem you can create separate sub-pools for the different contexts using <no-tx-separate-pools/>.

The pool is designed for concurrent usage.

Upto <max-pool-size/> threads can be inside the pool at the same time (or using connections from a pool).

Once this limit is reached, threads wait for the <blocking-timeout-seconds/> to use the pool before throwing a No Managed Connections Available

The number of connections in the pool is controlled by the pool sizes.

The pool filling is done by a separate "Pool Filler" thread rather than blocking application threads.

You can configure connections to be closed when they are idle. e.g. If you just had a peak period and now want to reap the unused ones. This is done via the <idle-timeout-minutes/>.

Idle checking is done on a separate "Idle Remover" thread on an LRU (least recently used) basis. The check is done every idle-timeout-minutes divided by 2 for connections unused for idle-timeout-minutes.

The pool itself operates on an MRU (most recently used) basis. This allows the excess connections to be easily identified.

Should closing idle connections cause the pool to fall below the min-pool-size, new/fresh connections are created.

The JDBC protocol does not provide a natural connectionErrorOccured() event when a connection is broken. To support dead/broken connection checking there are a number of plugins.

Thirdparty Pools - only if you know what you are doing