4 Replies Latest reply on Jun 21, 2006 11:28 AM by bviveiros

    createSession slow under load. (or createQueueSession)

    bviveiros

      When I test my application under load the createSession(true, Session.SESSION_TRANSACTED) method becomes my bottleneck. I've seen it take up to 2 seconds to return.

      Can someone explain what is happening in this method that might be slowing things down?

      Setup:
      - JBoss AS 4.0.3SP1
      - The application and the queue are running on the same server.
      - The app has a servlet that does the following:
      1. Lookup the UserTransaction.
      2. Begin a new Transaction
      3. Get a Hibernate session
      4. Create a JMS Session
      5. Performs some database queries and inserts using Hibernate.
      6. Post a message to the queue
      7. Commit the UserTransaction

      Thanks.

        • 1. Re: createSession slow under load. (or createQueueSession)
          genman


          Interesting. Are you using the JCA adapter, i.e. "java:/JmsXA"? You should use this to obtain a new JMS connection each time.

          • 2. Re: createSession slow under load. (or createQueueSession)
            bviveiros

            Yes, I'm using the JmsXA to create a connection on each request.

            Any idea what the createQueueSession method might be waiting on?

            Is there a connection pool setting that I should play with? I tried changing the max-pool-size on the JmsXA resource but it didn't seem to have any effect.

            Also, not sure if this matters but to simplify my database setup I have my app tables, jBPM tables, and JMS tables in the same schema. This way they are managed by one local datasource. Not sure that it is best practices but it got me up and running quickly for the proof of concept that I'm building.

            • 3. Re: createSession slow under load. (or createQueueSession)
              bviveiros

              Here's a code snippet:

              InitialContext iniCtx = new InitialContext();
              
              Object tmp = iniCtx.lookup("java:/JmsXA");
              QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
              QueueConnection jmsConn = qcf.createQueueConnection();
              
              jmsConn.start();
              
              Session sess = jmsConn.createQueueSession(true, Session.SESSION_TRANSACTED);


              • 4. Re: createSession slow under load. (or createQueueSession)
                bviveiros

                Found the problem. I needed to increase the max-pool-size significantly (to 100 for now) to get past that bottleneck. I'll have to play with that number until I find the optimal setup for my app.

                Thanks.