如何限制 Glassfish v3 上 MDB 池的大小

发布于 2024-10-18 11:55:44 字数 1112 浏览 4 评论 0原文

我的消息驱动 Bean 执行高度密集的操作,因此我想限制它的池大小,否则我的服务器会过载。我已经尝试过这个(代码),但它不起作用,它的池仍然是32(根据经验测试,我不时重新启动服务器,因此没有池实例)。

@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 {

我在 JDK 6 上的 Glassfish v3 上使用 EJB 3。应用程序使用 EE 6 标准。

你能帮我看看如何限制池吗?感谢您的任何帮助。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

往事随风而去 2024-10-25 11:55:44

我建议创建一个 sun-ejb-jar.xml 并将池配置放在那里。请参阅 http://www.sun 中的 bean-pool。 com/software/appserver/dtds/sun-ejb-jar_3_1-0.dtd 了解原始、血腥的细节。请参阅 http://download 中的 bean-pool。 oracle.com/docs/cd/E19798-01/821-1750/6nmnbjlfi/index.html 了解详细信息,精心打磨。

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.

卖梦商人 2024-10-25 11:55:44

我关注了 @vkraemer 发布的链接,下面是我的代码片段。似乎还需要steady-pool-size和resize-quantity,因为它们的默认值与较低的最大池大小不兼容。

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

但请注意

设置较小的max-pool-size可能会导致过多的对象破坏
(并因此导致过多的对象创建)实例被销毁
如果当前池大小超过 max-pool-size,则从池中取出。

...来自 GlassFish 性能调整指南

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文