6 Replies Latest reply on Jan 14, 2010 9:52 AM by jaikiran

    How to limit the stateful SB pool size?

      I'm trying to pick up the basics of EJB3 and JBoss.  I'm following a tutorial that demonstrates the stateful session bean lifecycle, forcing passivation and activation, by limiting the pool of stateful session beans to one less than the number in use.

       

      How is this achieved?  With EJB3, can I write a jboss.xml file as follows?

      <

       

      jboss>

       

           <enterprise-beans >

       

                <session>

       

                     <ejb-name>CountBean</ejb-name>

       

                     <configuration-name>Limited Poolsize Stateful SessionBean</configuration-name>

       

                </session>

           </enterprise-beans>

           <container-configurations >

       

                <container-configuration extends="Standard Stateful SessionBean">

       

                     <container-name>Limited Poolsize Stateful SessionBean</container-name>

       

                     <container-cache-conf>

       

                          <cache-policy>org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy</cache-policy>

       

                          <cache-policy-conf>

       

                               <max-capacity>2</max-capacity>

                          </cache-policy-conf>

       

                     </container-cache-conf>

       

                     <container-pool-conf>

       

                          <MaximumSize>2</MaximumSize>

       

                          <strictMaximumSize>true</strictMaximumSize>

                     </container-pool-conf>

       

                </container-configuration>

           </container-configurations>

      </jboss>

       

      If I deploy the bean with this jboss.xml file in the META-INF folder then the bean works but does not passivate and activate.  Is my jboss.xml file correct?  Do I need to deploy it somewhere else?

       

      I found this post online:  http://community.jboss.org/message/515942

      If I follow the direction in this post, to instead modify the ejb3-interceptors-aop.xml file, then I get the desired result, but this method is more complex and I haven't read anything that says EJB3 doesn't suppor the jboss.xml file.

       

      Can anyone confirm the simplest way to limit the pool of stateful session beans, both generically, and on a per bean class basis?

       

      Thanks!