5 Replies Latest reply on Oct 10, 2003 8:27 AM by amol

    Entity Bean Instance pooling

      Hello ,

      I have one sample "Student" Entity Bean(CMP) example which demonstrates the the Jboss Application server do not use any instance pooling.
      It Creates a new Instance every time , I send a request to it.

      My example first added 20,000 rows in Student table with schema (id,firstname,lastname,address).

      the row is (id++,'test','test','test') with id start with 0.

      I inserted this row using StudentHome.create(StudentValueObject) 20,000 times in a for loop.
      Each time I iterate through this loop , container creates a new Instance of StudentEntityBean. I watched this by Putting Sys.out.println inside no argument constructor of my StudentBean.


      It takes around 30 mins to add 20,000 rows on a machine with 256MB RAM.

      One more thing , when i use findByName('test') , it returns me a collection of StudentRemote Objects of size 20,000 ;

      Againg when I iterate through this collection to print the student (fname.lname,address) , it creates the new Instance of StudentBean for each iteration.

      I think this demonstrates that JBoss do not use any instance pooling , it simply creates new entity bean instance every time.

      Regards,

        • 1. Re: Entity Bean Instance pooling

          No guru to answer this ??

          • 2. Re: Entity Bean Instance pooling

            The instances are cached (commit option B) by default.

            Most likely you are stopping and starting transactions on
            every operation?
            JBoss will keep the bean instances but not the data
            under option B.

            Regards,
            Adrian

            • 3. Re: Entity Bean Instance pooling

              Sir,

              can you please put more light on it (commit option A and B) , how they will help in instance pooling.

              • 4. Re: Entity Bean Instance pooling

                Read the spec.

                Instance pooling/caching is NOT your problem.

                Transactions and/or read-ahead configuration are your problem.

                Enable DEBUG for org.jboss.ejb.plugins in conf/log4j.xml
                the look at log/server.log
                I can pretty much guarantee you are seeing continual loading
                due to some variation of the N+1 problem

                Regards,
                Adrian

                • 5. Re: Entity Bean Instance pooling

                  Sir ,

                  I observed one more thing :

                  after ejbpassivate , container always calls unsetEntityContext .

                  This means that container destroyes the instance instead of putting it on pool.

                  is there any way , by which I can get current number of instances in a pool.

                  regards,