I noticed that when there are many requests and the max pool size is reached, other requests wait until a resource is free. How do I setCommonsPoolTargetSource
such that when it reaches its max pool size, new object instances will be created? The excess resources must also be release after it's used.
Initially, I tried looking for a minSize
property but found out that CommonsPoolTargetSource
does not have a minSize
property. Below is the body of my web.xml:
<bean id="simpleBeanTarget" class="com.bean.SimpleBean" scope="prototype">
</bean>
<bean id="poolTargetSource" class="org.springframework.aop.target.CommonsPoolTargetSource">
<property name="targetBeanName" value="simpleBeanTarget" />
<property name="maxSize" value="3" />
<!-- How do I let the pool grow if more than 3 instances is needed? -->
<!-- And how do I release the excess instances after usage? -->
</bean>
<bean id="simpleBean" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="targetSource" ref="poolTargetSource" />
</bean>
Try <property name="whenExhaustedActionName" value="WHEN_EXHAUSTED_GROW" />
or
<property name="whenExhaustedAction">
<util:constant static-field="org.apache.commons.pool.impl.GenericObjectPool.WHEN_EXHAUSTED_GROW"/>
</property>