Like all other components, your resource pool is created and configured through properties files. You can use the following properties to configure a resource pool:

min

The property min sets the minimum number of resources the pool should start out with. Since resource creation can be expensive, some applications will want a starting minimum number of resources already in the pool before the pool becomes active. This minimum is only a starting minimum and will not be maintained throughout the life of the pool. As invalid resources are checked back into the pool, the number of pooled resources can drop below the starting minimum. After startup, resource creation is driven by resource demand.

max

The maximum number of objects that may be kept in the pool. This includes both free objects and objects already in use.

blocking

If someone tries to check out a resource, and all of the free resources are currently checked out, then the resource pool will create a new resource. But if the max number of resources has been reached, then the resource pool can perform one of the two following actions, depending on the value of the blocking property:

checkoutBlockTime

You can use this property to set a limit on how long a resource pool can block. The value of this property is the maximum time in milliseconds to block waiting for a resource on checkout. If this time limit is reached, then an exception is thrown. A value of zero (the default) indicates indefinite blocking.

warnOnNestedCheckouts

This setting enables or disables warnings about nested resource checkouts that might cause deadlocks.

maxFree

Certain types of resources may be expensive to keep around if they are not being used. In this case, you may want to limit the number of resources kept around unused. The maxFree property indicates how many resources are to be kept around that aren’t in use by other services. This may be different from the max property, which indicates how many total resources are to be kept, both used and unused.

If, when a resource is checked into the pool, the number of resources then in the pool is greater than both the maxFree property and the min property, then the pool destroys the resource being checked.

The default value for maxFree is -1, indicating that the number of maximum free resources is not limited except by the max property. This will usually be the case, since there is rarely a need to destroy unused resources.

maxSimultaneousResourcesOut

When you are designing your application, it can be difficult to predict how many resources you need to make available in a pool. The maxSimultaneousResourcesOut property keeps track of the largest number of resources that have ever been checked out of the resource pool at one time. You can examine this property during testing and after deployment to get an idea of the maximum number of resources your application requires. If the value of maxSimultaneousResourcesOut is significantly less than the value of max, you can probably reduce the size of your resource pool.

maxThreadsWithResourcesOut

The maximum number of threads that can have resources checked out of the pool concurrently.

maxResourcesPerThread

The maximum number of resources a thread can check out of the pool concurrently.

 
loading table of contents...