2 Replies Latest reply on Jun 22, 2009 4:33 PM by chtimi2

    What is the correct object to hold in an EJB for transaction

      It is often said here (for good reason) that creating a JMS connection per request is an anti-pattern, but there is something i'm not quite clear about.
      Should i maintain in my EJBs a reference to a session, a message producer, something else?

      With a persistence unit in a Stateless, the transaction is per request and the persistence context is per request too (after that the entities are detached from the session).

      So if i translate this from JPA to JMS and JBM, shouldn't the session be in the same scope as the transaction?
      But if in a Stateless i hold a reference to a JMS session, for instance created from the ConnectionFactory in a PostConstruct method, that session will last longer than the request because the EJB is pooled (and if wasn't there would be no point in holding the Session rather than the SessionFactory)

      But then the JMS interfaces are ConnectionFactory not SessionFactory so maybe they are more like JDBC connections and if so how?