1 Reply Latest reply on Jan 4, 2013 5:48 PM by Justin Bertram

    Should I cache JMS Connections with JBoss AS 7 ?

    Mylos Kathos Master

      Hello! happy new year to everybody !

      I have the following question: I have an EJB application which sends some JMS messages:


      @Resource(mappedName = "java:jboss/jms/queue/dlmsQueue")

      private Queue queueExample;


      @Resource(mappedName = "java:/ConnectionFactory")

      private ConnectionFactory cf;


      private Connection connection;

      public void sendMessage(String msg) {



          connection = cf.createConnection();


              . . . . 


      The JMS ConnectionFactory and the Queue are injected, however the Connection is created every time. Is this a good pattern or should I cache the Connection object ? (maybe in a @PostConstruct method)

      I have read here https://community.jboss.org/wiki/ShouldICacheJMSConnectionsAndJMSSessions that the JCA layer might be able to intercept and cache the call, however I would like to check it somehow.

      Any help ?