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:


The property min sets the minimum number of resources the pool should start out with. Because resource creation can be expensive, some applications require a starting minimum number of resources already in the pool before the pool becomes active. This minimum is only a starting minimum and is not 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.


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


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


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, an exception is thrown. A value of zero (the default) indicates indefinite blocking.


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


Certain types of resources can be expensive to keep around if they are not being used. In this case, you might want to limit the number of resources kept around unused. The maxFree property indicates how many resources are to be kept around that are not in use by other services. This might 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, 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 is usually the case, as there is rarely a need to destroy unused resources.


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 were 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.


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


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