Discussions

EJB design: Container demarcated transactions

  1. Container demarcated transactions (1 messages)

    I have a session bean, marked as TX_REQUIRED, which talks to several different beans, entity beans marked as TX_MANDATORY and session beas marked as TX_REQUIRED. The entity beans are BMP entities and use JDBC to write to the database. The session beans use JMS and transacted sessions to write to a queue.
    The problem is that the connections to both the queue and JDBC do not seem to be tied into the transaction stated by the container.
    Am I missing something?

    Thanks!
  2. Container demarcated transactions[ Go to top ]

    Well, first, JMS transaction sessions and UserTransactions do not mix at all, unless you are using WLS 6.0 with XA transactions.

    When you create a transacted JMS session, that session operates independently of any commits and rollbacks of the UserTransaction associated with the thread. This happens because a JMS session IS a separate thread than the one that created the session. So, if you have a thread that is infected with a UserTransaction due to a method invocation, a JMS session created by that thread will not have the UserTransaction passed onto it.

    In WLS 6.0, there are four different configurations that you can setup. One of the configurations (the exact name of which I can't recall right now) will allow your JMS sessions to inherit the UserTransaction.

    As for your session beans and database not picking up the transaction: 1) make sure you are getting your transaction from a connection pool or a transactional datasource. How are you getting your JDBC connection now? 2) If you are using stateless session beans, the SessionSynchronization methods will not be invoked if that is what you are looking for.

    Tyler