7 Replies Latest reply on Mar 20, 2009 10:00 AM by ataylor

    caching the initial session created

    ataylor

      Currently when we create a new jms connection we only actually create a session if we are authenticating and then we close it once authentication has taken place.

      I'm changing this so that firstly we always authorize and secondly caching the initial session and reusing it for the first actual session created. The only issue is that the initial core session is created with xa, autoCommitSends, autoCommitAcks and preAcknowledge set to false and ackBatchSize set to 0. O though the best thing was to add an extra method to core session to allow these values to be reset.

        • 1. Re: caching the initial session created
          ataylor

          also when the last session is closed we keep the initial connection open. This can be used for deleting tempqueues als when the connection is actually closed

          • 2. Re: caching the initial session created
            timfox

             

            "ataylor" wrote:
            Currently when we create a new jms connection we only actually create a session if we are authenticating and then we close it once authentication has taken place.

            I'm changing this so that firstly we always authorize and secondly caching the initial session and reusing it for the first actual session created. The only issue is that the initial core session is created with xa, autoCommitSends, autoCommitAcks and preAcknowledge set to false and ackBatchSize set to 0. O though the best thing was to add an extra method to core session to allow these values to be reset.


            Not sure that is a good idea. You'd have to change the values on the server too, that means adding a new wire format message - pretty ugly.

            I'd say just cache the special session locally in the jms connection and only use it for initial authorisation and delting temp queeus etc.

            • 3. Re: caching the initial session created
              ataylor

              ok thats fine, I was just wondering how we would deal with this at a management leve, for instance the following test:

              Connection connection = JMSUtil.createConnection(connectorFactory);
              connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
              assertEquals(1, service.getServer().getConnectionCount());
              


              would always fail since there are actually 2 connections, is that fine?

              • 4. Re: caching the initial session created
                timfox

                What test is that?

                • 5. Re: caching the initial session created
                  ataylor

                  JMSServerControl2Test, the point is if there is 1 connection with 1 session, service.getServer().getConnectionCount() will return 2.

                  • 6. Re: caching the initial session created
                    timfox

                    Well, are there two sessions or one session?

                    If you're creating two sessions now, then you need to reflect that in the asserts too, right?

                    • 7. Re: caching the initial session created
                      ataylor

                      aye, thats what Ive done.