8 Replies Latest reply on Jun 7, 2007 6:12 AM by James Callaghan

    Stateless minimum pool size

    James Callaghan Newbie

      Is it possible to set the minimum pool size for a stateless session bean as an annotation in the bean itself or can this only be done in the jboss.xml file?

        • 1. Re: Stateless minimum pool size
          Carlo de Wolf Master

          There currently is no minimum pool size for session beans.

          • 2. Re: Stateless minimum pool size
            James Callaghan Newbie

            What about this stuff in the standardjboss.xml file in conf?

            <container-pool-conf>
            <MinimumSize>100</MinimumSize>
            <MaximumSize>100</MaximumSize>
            <strictMaximumSize/>
            <strictTimeout>30000</strictTimeout>
            </container-pool-conf>
            </container-configuration>
            


            • 3. Re: Stateless minimum pool size
              Carlo de Wolf Master

              That's the default configuration for the EJB 2 deployer. Nothing to do with EJB 3 deployer.

              • 4. Re: Stateless minimum pool size
                James Callaghan Newbie

                OK. Well I've got a Stateless Session Bean (EJB3) that does a load of initialisation (hibernate) in it's @PostConstruct method. I don't really want this initialisation to be done every time I use the bean so I was hoping to pool a few of them and take them from the pool as required. It's killing performance at the moment because they don't seem to be pooled. Thus, I was trying to force there to be a minimum of five bean instances in the method ready pool.

                If this is not possible, is there another clever way I can do the initialisation and reference it in the bean?

                • 5. Re: Stateless minimum pool size
                  Carlo de Wolf Master

                  The beans are pooled inside the ThreadlocalPool. This means that each remoting thread is given an instance when asked. Depending on how many remoting threads you have it can take a while for the whole ThreadlocalPool to fill up.

                  You can switch to a more traditional pool: StrictMaxPool, but this does introduce congestion on the semaphore regulating the pool.

                  A completely different approach would be to optimize cache usage of your entities.

                  Commonly the PostConstruct is only used for setting up resource connections to slow XA resources. You shouldn't store any data there that is common accross multiple stateless beans or data that is really state.

                  • 6. Re: Stateless minimum pool size
                    James Callaghan Newbie

                    Thanks for your help mate... In the end I've opted for a little change in the architecture. Previously I was building the session factory etc in the post construct method for each bean. Now, when I need the session factory and a new session I get it from JNDI. If it isn't there, I create it and add it into JNDI first. This way I'm only getting the initialisation done once.

                    However, it seems I've got some reading to do on configuration of pools!

                    • 7. Re: Stateless minimum pool size
                      Carlo de Wolf Master

                      GG. If possible try to write it up as a JBoss service / MBean. That way you can just deploy the session factory and have it available. It will also allow you to control the session factory through JMX.
                      You can do this using @Service, but that API hasn't been solidified yet.

                      • 8. Re: Stateless minimum pool size
                        James Callaghan Newbie

                        I did some research into that before but got a little scared off. We have multiple applications on the same server and I'm worried about sharing the same hibernate SessionFactory between all of these applications. I've already seen problems when redeploying (hot-deploying) an application in that when it tries to use the hibernate session factory from the previous deployment we get a load of class cast errors.