5 Replies Latest reply on Sep 17, 2003 1:44 PM by Adrian Brock

    queue connection

    Mike Hemling Newbie

      I am fairly new to JBOSS and JMS and would like to know the best way to send data to a queue. Is the "correct" way to open and close a connection for every send? We are processing thousands and thousands of requests and we need speed. It would seem to me that opening and closing a queue connecton each time would be slow.

      I have tried opening the connection once and never closing and it does seem to speed things up but then the server occastionally hangs up. Please enlighten me. Like I said, we need stability and throughput.

      thanks!

        • 1. Re: queue connection
          Adrian Brock Master

          The best method is to "pool" sessions.
          Your lockup is probably due to concurrent use of session
          objects that is not externally synchronized. See the spec.

          Regards,
          Adrian

          • 2. Re: queue connection
            Mike Hemling Newbie

            thanks.

            When you say "pool" sessions do you mean create a connection to the queue once and never close and use multiple sessions? Let's assume that data keeps flowing into my application. I then need to get the data onto the queue quickly without opening and closing a connection each time.

            How do you go about session pooling?

            I had a suspicion that I needed to synchronize my calls. I had assumed that JBOSS took care of that.

            thanks again

            • 3. Re: queue connection
              Adrian Brock Master

              JBoss takes care of it inside the appserver.
              See the jca connectionfactory "java:/JmsXA" defined in
              jms-ds.xml

              It is supposed to be usable on a client, but I've
              never tried it.

              Regards,
              Adrian

              • 4. Re: queue connection
                Mike Hemling Newbie

                In theory, as long as I keep everything synchronized can I have ONE connection that I never close?

                My front end is a socket server that connects to a queue. I only need one connection. I do not want a connection going up and down everytime.

                • 5. Re: queue connection
                  Adrian Brock Master

                  Provided you externally synchronize on the session
                  before sending messages, yes.

                  This will be less performant than creating one
                  session for each thread and depending on the
                  bandwidth/latency you might want to create multiple connections? Think of the connection as a pipe with
                  multiple inlets (the sessions).
                  The connection is internally synchronized, the session
                  is not.

                  Regards,
                  Adrian