3 Replies Latest reply on Jul 7, 2015 8:01 AM by gytis

    Running the RTS bridge in container other than Wildfly

    peterfry

      Hi,

       

      I am interested in trying to run the RTS bridge in a OSGi environment such as Apache Karaf (so that REST-AT can be demonstrated across two different container types and also two different Transaction Manager types). The main RTS service will continue to run in Wildfly.

       

      I'd prefer not to have to switch to running Narayana as the Transaction Manager type in the Apache Karaf container (I see that there is a OSGi module in the Narayana repo which has a Karaf Arquillian  container test). That means attempting to get the RTS bridge to work with Apache Aries i.e. a OSGi JAXRS REST service will use the InboundBridgeFilter which in turn will access a remote enlistmentUrl of an existing Wildfly RTS service.

       

       

      From what I can see a crucial element in the InboundBridge is

       

        /**

        * Get the JTA subordinate transaction with current XID.

        *

        * @return

        */

        private Transaction getTransaction() {

          final Transaction transaction;

       

          try {

            transaction = SubordinationManager.getTransactionImporter().importTransaction(xid);

          } catch (XAException e) {

            LOG.warn(e.getMessage(), e);

            throw new InboundBridgeException("Failed to import transaction.", e);

          }

       

          return transaction;

        }

       

      The concrete implementation of javax.transaction.Transaction being returned is Narayana specific, not really sure what importTransaction is doing.

       

      The enlistment of the InboundBridge in the JTA transaction seems pretty straightforward:

       

          private void enlist(final InboundBridge inboundBridge) {

              final Transaction transaction = getTransaction();

       

       

              if (!isTransactionGoodToEnlist(transaction)) {

                  throw new InboundBridgeException("Transaction is not in an active state.");

              }

       

       

              try {

                  transaction.enlistResource(inboundBridge);

              } catch (Exception e) {

                  LOG.warn(e.getMessage(), e);

                  throw new InboundBridgeException("Failed to enlist inbound bridge to the transaction.", e);

              }

          }