5 Replies Latest reply on Jul 22, 2008 12:55 AM by timfox

    Spring JmsTemplate questions

    theoverlord

      First I'll describe my configuration.

      I'm sending a message from a JBoss AS to a remote queue on another JBoss AS using Spring's infamous JmsTemplate to send the message.

      I read the advice concerning the use of Spring's JmsTemplate but I inherited this code so i'm hesitant to remove all references to JmsTemplate.

      I read that I can use Spring's SingleConnectionFactory to reuse the JMS connection.

      I have some question about this though.

      It's my understanding that a single QueueConnectionFactory can be shared among different threads - is that correct?

      It's also my understanding that a single connection created from a QueueConnectionFactory can be shared by multiple threads - is that correct?

      If that is all correct, then why do I keep on reading about JMS connection pooling if the connection can be shared ? If they can be shared, you don't need a pool, you just need one connection - right?

      I think I'm not understanding something correctly.

      Please enlighten me.

        • 1. Re: Spring JmsTemplate questions
          clebert.suconic


          The problem with JMSTemplate on Spring is about the session.

          Spring will create a JMSSession on every send:

          session = conn.createSession(....);
          ....
          producer = session.createProducer...
          producer.send(....)



          And those are expensive operations *on any* messaging system (as far as I know).

          • 2. Re: Spring JmsTemplate questions
            theoverlord

            According to the JBoss Wiki relating to JmsTemplate, it's safe to use JmsTemplate so long as it's used in a Jboss AS when using the connection factory from "java:/JmsXA".

            • 3. Re: Spring JmsTemplate questions
              clebert.suconic

               

              According to the JBoss Wiki relating to JmsTemplate, it's safe to use JmsTemplate so long as it's used in a Jboss AS when using the connection factory from "java:/JmsXA".


              I assumed you knew that...

              I'm just saying why you need to ensure you use java:/JmsXA.

              • 4. Re: Spring JmsTemplate questions
                theoverlord

                Even though it's safe to use the JmsTemplate in some specific cases, are you saying it may not be the most efficient in those cases?

                • 5. Re: Spring JmsTemplate questions
                  timfox

                   

                  "TheOverlord" wrote:
                  According to the JBoss Wiki relating to JmsTemplate, it's safe to use JmsTemplate so long as it's used in a Jboss AS when using the connection factory from "java:/JmsXA".


                  And even then, it's only safe for sending messages, not consuming them.