8 Replies Latest reply on Jan 22, 2005 7:21 AM by arnold

    JMS Connection pooling???

    emater

      Hi All,

      Is there a concept of JMS connection pooling like JDBC connection pooling? I'd appreciated if some idea about the subject below:

      Suppose that:

      I have a bussiness delegate XXXDelegate class which opens a JMS connection to a JBossMQ and put some messages to the sample queue XQueue.

      This delegate has a Singleton getInstance() method which returns a new instance of this XXXDelegate.

      public static XXXDelegate getInstance() {
      if (instance == null) {
      instance = new UserManagerDelegate();
      }
      return instance;
      }


      Again this delegate has a static doJob() method which opens the JMS connection and put messages to the queue.

      public static void doJob() {
      // open jms connection
      // put a message to a queue on JBoss Queue
      }


      In a servlet when someone pushes a submit button command below is executed.

      XXXDelegate.getInstance().doJob();

      Now, how is the difference between these two below:
      If a servlet from web tier calls this delegate only once and let's say concurrent 20 calls occurs.

      Is that mean, 20 new jms connections will be opened or because of singleton getInstance() method just one connection will be opened and others will wait for the first one to finish its job.

      Thanks for any help

        • 1. Re: JMS Connection pooling???

          You can use the connection factory at
          java:/JmsXA this actually pools sessions
          the connection is the inVM version.

          Regards,
          Adrian

          • 2. Re: JMS Connection pooling???
            emater

            Adrian,

            Thank you. I need more info about that. Could you direct me a documentation other than QuickStart-30x.pdf (I've read that) which may have some example related to this?

            I also need to understand what happens in one life-cycle if two concurrent call occur from servlet.

            Regards,

            • 3. Re: JMS Connection pooling???

              Well there is the for pay docs or this forum
              (it gets a mention quite often).
              Other than that there is the source.

              I don't understand the second question?

              Regards,
              Adrian

              • 4. Re: JMS Connection pooling???
                emater

                Well, second question was not directly related to JMS. It concerns singleton pattern and multi threading.

                Question was what happens if 10 people at the same time calls delegate? (I explained it in my first email)

                Singleton returns just one instance. But ten people try to get an instance at the same time. Is that means 9 other threads will wait for first one to finish its jms connection job. Or every 10 thread would have same instance opening a JMS connection. I need to visualize things in more detail.

                Well if what I am asking is meaningless don't worry about it. Thanks for that anyway...

                • 5. Re: JMS Connection pooling???

                  The JMS connection can be accessed on multiple
                  threads. The sessions cannot. It is explained
                  in the spec/javadocs.

                  Does that answer your question?

                  Regards,
                  Adrian

                  • 6. Re: JMS Connection pooling???
                    emater

                    Yep. I got my answer. I was thinking of opening one JMS connection and without closing it, my threads, which are created by servlet, would open and close JMS sessions inside it.

                    So, I understand that I should use JMS conn. pooling instead of opening and closing sessions inside one JMS connection.

                    One last question: How will I get JMS connection from JMS pool. Is it like JDBC pooled connection? Any sample code?

                    Is there something like getPooledQueueConnection() or what?

                    Thank you.

                    • 7. Re: JMS Connection pooling???

                      See above, it is bound into jndi at java:/JmsXA

                      Regards,
                      Adrian

                      • 8. Re: JMS Connection pooling???
                        arnold

                        Hi Adrian,

                        I have set up JMS connection pooling using java:/JmsXA, but running into problem with durable subsctriptions.

                        Is there a way to set the client ID on the connection obtained from the pool? JBoss throws error when I try to call setClientID() on the connection object.

                        I am using JBoss 3.2.4

                        Regards,
                        Arnold