1 Reply Latest reply on Jun 22, 2016 6:13 AM by Miroslav Novak

    Difference between org.apache.activemq.ra.ActiveMQManagedConnectionFactory and org.apache.activemq.pool.PooledConnectionFactory

    Kaustav Mandal Newbie

      Hi ,

       

      I am currently looking at the benefits of using Spring based pooling using org.apache.activemq.pool.PooledConnectionFactory versus the JNDI approach using the org.apache.activemq.ra.ActiveMQManagedConnectionFactory  in JBOSS EAP 6.3.

      I did see that in the JNDI configuration we can only specify minimum and maximum pool sizes.

      However, while using the PooledConnectionFactory in Spring, we can specify maximumConnections as well as maximumActiveSessions per connection.

       

      Which one would be better ? Is  there any way to specify the number of sessions per connection in the ActiveMQManagedConnectionFactory  JNDI configuration ?

       

      In the application, I do not create any sessions as I just pass the PooledConnectionFactory or the JndiObjectFactoryBean to the JmsTemplate depending on which type of pooling, is being used in the application.

       

      Edit:

      Looking at this post Should I cache JMS connections and JMS sessions? , it says the following :

       

      If you find yourself using any other JMS connection factories from within your EJB, MDB or servlet, e.g. java:/ConnectionFactory or java:/XAConnectiomFactory then it's almost certainly NOT the wrapped JCA connection factory, so your performance *will suck* if you're calling createConnection(), createSession() etc every time your method is invoked, since a raw JMS connection factory will provide *no caching*. You have been warned!

       

      I am not sure if that applies to this case or not.

       

      Thoughts ?

       

      Any input is greatly appreciated.

       

      Message was edited by: Kaustav Mandal

        • 1. Re: Difference between org.apache.activemq.ra.ActiveMQManagedConnectionFactory and org.apache.activemq.pool.PooledConnectionFactory
          Miroslav Novak Master

          You have very good question. I'll try to explain. If you have simple JMS ConnectionFactory (as defined in JMS specification) then there is no connection pooling. In this case it's anti-pattern to create->close connection for every message because it's expensive and performance bottleneck. Unfortunately this is exactly what Spring does.

           

          Basically connection pooling is solution.

           

          PooledConnectionFactory is providing connection pooling above what simple JMS ConnectionFactory can do. But if offers nothing else. ActiveMQManagedConnectionFactory offers more than just connection pooling. It allow to use some other features which from application server (EAP 6.x). For example you can have XA transaction associated with your connection or also use security domains defined in application server.

           

          So recommendation is that if you do not need any application server features then you probably get better performance with PooledConnectionFactory. If you need them or you just want to be on the safe side then use ActiveMQManagedConnectionFactory.