6 Replies Latest reply on Sep 8, 2011 1:38 AM by dro_k

    Re-using of HornetQ Core API Objects

    dro_k

      The following is from the Tuning seciton of the User Manual:

       

      Re-use connections / sessions / consumers / producers. Probably the most common messaging anti-pattern we see is users who create a new connection/session/producer for every message they send or every message they consume. This is a poor use of resources. These objects take time to create and may involve several network round trips. Always re-use them.

      Note

      Some popular libraries such as the Spring JMS Template are known to use these anti-patterns. If you're using Spring JMS Template and you're getting poor performance you know why. Don't blame HornetQ! The Spring JMS Template can only safely be used in an app server which caches JMS sessions (e.g. using JCA), and only then for sending messages. It cannot be safely be used for synchronously consuming messages, even in an app server.

       

      Considering that I'm using the Core API and not JMS as an embedded queue in my JVM (using InVmConnector), what objects should I re-use and more importantly how? How do you decide when to share a ClientSessionFactory, ClientSession, ClientProducer and ClientConsumer?

       

      Thanks,

       

      Drew