1 Reply Latest reply on Dec 22, 2007 12:23 PM by pmuir

    SMPC transaction propagation and REQUIRES_NEW

    asookazian

      SEAM2.0.0.GA
      JBOSS4.2.1.GA

      I'm currently using multiple SMPC's (for multiple DB's) that are configured in the components.xml. Also using flushMode=MANUAL for @Begin method to ensure that transactions are atomic (i.e. no premature updates before conversation ends). Seems to be working ok so far!

      I'm trying to understand the impact of the below statement from the ref pdf. It sounds like Seam is violating the EJB3 spec in this regard. This part is what I'm concerned about:


      However as the Seammanaged persistence context is propagated to any component within the conversation, it will be propagated to
      methods marked REQUIRES_NEW.


      When a method is marked REQUIRES_NEW, afaik, the current transaction is suspended until the method marked REQUIRES_NEW is completed. REQUIRES_NEW indicates that the method should always be executed inside a new transaction context.

      So I'm assuming in this case an exception would be thrown if you use SMPC and REQUIRES_NEW in case a transaction would be propagated. I tried it from a JSF getter method call to a method marked REQUIRES_NEW in a SFSB and there are no issues (but in that case apparently there is no transaction propagation)...

      If you are using EJB3 and mark your class or method @TransactionAttribute(REQUIRES_NEW) then the transaction
      and persistence context shouldn't be propagated to method calls on this object. However as the Seammanaged
      persistence context is propagated to any component within the conversation, it will be propagated to
      methods marked REQUIRES_NEW. Therefore, if you mark a method REQUIRES_NEW then you should access the entity
      manager using @PersistenceContext.


      --pg. 116 of JBoss Seam 2.0.0.GA ref pdf