0 Replies Latest reply: Sep 7, 2012 3:36 AM by 886995 RSS

    Join multiple transactions in one

    886995
      Hi.

      My scenario looks like
          Hashtable<String, Object> firstServerEnv = new Hashtable<String, Object>();
          firstServerEnv.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
          firstServerEnv.put(Context.PROVIDER_URL, "t3://myFirstServer:7101");
          final Context firstServerContext = new InitialContext(firstServerEnv);
          UserTransaction firstServerTransaction = (UserTransaction)firstServerContext.lookup("javax.transaction.UserTransaction");
          // lookup for first EJB
      
          Hashtable<String, Object> secondServerEnv = new Hashtable<String, Object>();
          secondServerEnv.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
          secondServerEnv.put(Context.PROVIDER_URL, "t3://mySecondServer:7101");
          final Context secondServerContext = new InitialContext(secondServerEnv);
          UserTransaction secondServerTransaction = (UserTransaction)secondServerContext.lookup("javax.transaction.UserTransaction");
          // lookup for second EJB
      
          Hashtable<String, Object> thirdServerEnv = new Hashtable<String, Object>();
          thirdServerEnv.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
          thirdServerEnv.put(Context.PROVIDER_URL, "t3://myThirdServer:7101");
          final Context thirdServerContext = new InitialContext(thirdServerEnv);
          UserTransaction thirdServerTransaction = (UserTransaction)thirdServerContext.lookup("javax.transaction.UserTransaction");
          // lookup for third EJB
      
          // Start global transaction
          // join firstServerTransaction, secondServerTransaction and thirdServerTransaction into one and begin transaction
          // execute methods from first EJB
          // execute methods from second EJB
          // execute methods from third EJB
          // Commit or rollback previously joined global transaction
      How to join all three transactions into one? Is it possible at all? What is practice of doing such thing?

      10x
      Regards