6 Replies Latest reply on Oct 17, 2011 5:37 PM by tomjenkinson

    Remote Tx Inflow: Proxying a transaction as an XAResource issue

    tomjenkinson

      I have started to implement (https://svn.jboss.org/repos/labs/labs/jbosstm/branches/JBOSSTS_4_15_0_Final_JBTM-895) the planned approach to facilitiate remoting being able to flow a transaction between servers but have come up against the following issue.

       

      Basically, the plan is to get the transport to register an javax.transaction.xa.XAResource that can intercept calls to javax.transaction.Transaction lifecycle management calls such as commit/rollback and relay those over to the remote transaction manager.

       

      This is all looking good until you realise that the signature for XAResource permits fewer exception types than the corresponding Transaction signature, resulting in a loss of prescision in the proxy code. As such as I tried to map the javax.transaction.Transaction exception types for commit/rollback using the available XA error codes.

       

      Just wondered if people can see any issues with the mappings I have done or can spot more appropriate ones:

      try {

      remoteManager.commit(xid);

      } catch (SecurityException e) {

      // This should never happen really as the root TM should have detected this

      throw new XAException(XAException.XAER_OUTSIDE);

      } catch (RollbackException e) {

      throw new XAException(XAException.XA_RBPROTO);

      } catch (HeuristicMixedException e) {

      throw new XAException(XAException.XA_HEURMIX);

      } catch (HeuristicRollbackException e) {

      throw new XAException(XAException.XA_HEURRB);

      } catch (SystemException e) {

      throw new XAException(XAException.XAER_PROTO);

      }

       

      try {

      remoteManager.rollback(xid);

      } catch (IllegalStateException e) {

      throw new XAException(XAException.XAER_NOTA);

      } catch (SystemException e) {

      throw new XAException(XAException.XAER_PROTO);

      }

       

      Comments/suggestions?