0
我注意到,當有很多請求並且達到最大池大小時,其他請求會一直等到資源空閒。如何設置CommonsPoolTargetSource
,以便在達到最大池大小時創建新的對象實例?多餘的資源必須在使用後釋放。如何讓CommonsPoolTargetSource池大小根據需要增長?
最初,我試圖尋找一個minSize
屬性,但發現CommonsPoolTargetSource
沒有minSize
屬性。下面是我的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>
嗨,路易斯!謝謝!我試着將'whenExhaustedActionName'設置爲'WHEN_EXHAUSTED_GROW',我的池正在增長。但是我使用這個新物體後,我的游泳池並沒有退縮到3。新的對象實例何時被刪除?如何刪除多餘的對象,如果在一段時間內處於非活動狀態? – Arci 2013-03-19 09:33:01
嘗試使用timeBetweenEvictionRunsMillis和minEvictableIdleTimeMillis屬性,默認情況下沒有驅逐。 – 2013-03-19 09:40:04
謝謝!將首先在CommonsPoolTargetSource的屬性上進行試驗。 :) – Arci 2013-03-19 10:01:38