How to restrict pool size of MDB on Glassfish v3

微笑、不失礼 提交于 2019-12-05 13:49:54

I would recommend creating a sun-ejb-jar.xml and put the pool configuration in there. See bean-pool in http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_1-0.dtd for the raw, gory details. See bean-pool in http://download.oracle.com/docs/cd/E19798-01/821-1750/6nmnbjlfi/index.html for the details, nicely polished.

I followed links posted by @vkraemer and bellow is my code snippet. It seems that steady-pool-size and resize-quantity are needed as well because their default values are not compatible with low max pool size.

<glassfish-ejb-jar>
    <enterprise-beans>
        <ejb>
            <ejb-name>SimpleClassName</ejb-name>
            <bean-pool>
                <steady-pool-size>1</steady-pool-size>
                <resize-quantity>1</resize-quantity>
                <max-pool-size>6</max-pool-size>
            </bean-pool>
        </ejb>
    </enterprise-beans>
</glassfish-ejb-jar>

But be aware of:

Setting a small max-pool-size can cause excessive object destruction (and as a result excessive object creation) as instances are destroyed from the pool if the current pool size exceeds max-pool-size.

... from GlassFish performance-tuning-guide

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!