How to restrict pool size of MDB on Glassfish v3

自作多情 提交于 2019-12-12 09:43:26

问题


my Message Driven Bean executes highly intensive operations so I would like to restrict it's pool size or my server would have been overloaded. I have tried this ( code ) but it doesn't work, it's pool is still 32 ( empirically tested, time to time I restart a server so there are no pooled instances ).

@MessageDriven( mappedName = "jms/TestTopic", activationConfig = {
    @ActivationConfigProperty( propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge" ),
    @ActivationConfigProperty( propertyName = "destinationType", propertyValue = "javax.jms.Topic" ),
    @ActivationConfigProperty( propertyName = "subscriptionDurability", propertyValue = "Durable" ),
    @ActivationConfigProperty( propertyName = "clientId", propertyValue = "Reader" ),
    @ActivationConfigProperty( propertyName = "subscriptionName", propertyValue = "Reader" ),
    @ActivationConfigProperty( propertyName = "endpointPoolMaxSize", propertyValue = "1" ),
    @ActivationConfigProperty( propertyName = "endpointPoolResizeCount", propertyValue = "1" ),
    @ActivationConfigProperty( propertyName = "endpointPoolSteadySize", propertyValue = "0" )
} )
public class Reader implements MessageListener {

I am using EJB 3 on Glassfish v3 on JDK 6. Application uses EE 6 standard.

Can you help me how to restrict the pool, please? Thanks for any help.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/5046852/how-to-restrict-pool-size-of-mdb-on-glassfish-v3

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