2 Replies Latest reply on Jan 16, 2016 8:34 AM by Erhard Siegl

    Can i use Oracle Tuxedo JCA Adapter in WildFly 9 to call my tuxedo backend service?

    ChingPin Hsu Newbie

      Hi, i am new here and hope that i entered the question in the right place.

      Our existing program is a JavaEE web application runs on WebLogic server and accessing Oracle database through Tuxedo services. In order to cut cost, we want to switch to WildFly 9 and keep the changes of our development as little as possible.

      My question is if we can use jatmi from "Oracle Tuxedo JCA Adapter" to call our tuxedo backend service without WebLogic? Since I found all the sample codes from Oracle includes "weblogic.wtc.jatmi.xxx", and even for the "IBM WebSphere" sample code.

      If I need to use other vender Tuxedo Adapter to call tuxedo backend service, which one is simple and easy (cost less...) to get start quickly. And some sample code will be nice!

      Thank you so much in advance for the help!

        • 2. Re: Can i use Oracle Tuxedo JCA Adapter in WildFly 9 to call my tuxedo backend service?
          Erhard Siegl Novice

          Hi,

           

          Yes you can use WildFly 9 with "Oracle Tuxedo JCA Adapter". We are using it with EAP 6 in production and I tried it with EAP 7.0.0.Beta, so I assume its working with Wildfly 9. When it come to cost, you need to be aware, that the Tuxedo Adapter needs to be licenced as well. I don't know any other Tuxedo adapters that work.

          You can use code similar to the following (this is not production-code!):

          import javax.annotation.Resource;
          import javax.ejb.Stateless;
          import javax.jws.WebService;
          import javax.naming.Context;
          import javax.naming.InitialContext;
          import javax.naming.NamingException;
          import javax.resource.ResourceException;
          import javax.resource.cci.Connection;
          import javax.resource.cci.ConnectionFactory;
          import javax.resource.cci.Interaction;
          import javax.resource.cci.InteractionSpec;
          
          
          import org.slf4j.Logger;
          import org.slf4j.LoggerFactory;
          
          
          import weblogic.wtc.jatmi.TPException;
          
          
          import com.oracle.tuxedo.adapter.cci.TuxedoInteractionSpec;
          import com.oracle.tuxedo.adapter.cci.TuxedoStringRecord;
          import com.oracle.tuxedo.adapter.cci.TuxedoXOctetRecord;
          
          @Stateless
          @WebService
          public class TuxCall implements ITuxCall {
          
          
              private final static Logger logger = LoggerFactory.getLogger(TuxCall.class);
          
          
              @Resource(mappedName="java:/ta2/tuxedo")
              private ConnectionFactory connectionFactory;
          
          
              private String jndiName = "java:/ta2/tuxedo";
              // private String jndiName = "java:comp/env/eis/tuxedo";
          
              public String toupper(String message) {
                   return callString("TOUPPER", message);
              }
          
              private String callString(String tmServiceName, String request) {
          
          
                  Connection connection;
                  TuxedoStringRecord outRec;
          
          
                  try {
                      logger.info("get Connection");
                      connection = getConnectionFactory().getConnection();
                      logger.info("got Connection");
                      outRec = interCall(tmServiceName, request, connection);
                      connection.close();
          
                      return outRec.getString();
                  } catch (NamingException ne) {
                      throw new RuntimeException(
                              "Fehler beim Holen der TuxedoConnectionFactory mit JNDI-name " + jndiName, ne);
                  } catch (ResourceException re) {
                      throw new RuntimeException(
                              "ResourceException beim Zugriff auf Tuxedo Service "+ tmServiceName+ ": ", re);
                  } catch (TPException e) {
                      throw new RuntimeException("Fehler beim Zugriff auf Tuxedo: ",
                              e);
                  }
              }
              private TuxedoStringRecord interCall(String tmServiceName, String request,
                      Connection connection) throws ResourceException, TPException {
                  Interaction ix;
                  TuxedoStringRecord inRec;
                  TuxedoStringRecord outRec;
                  TuxedoInteractionSpec ixspec;
          
          
                  logger.info("createInteraction");
                  ix = connection.createInteraction();
                  logger.info("got Interaction");
                  logger.info("create TuxedoInteractionSpec");
                  ixspec = new TuxedoInteractionSpec();
                  logger.info("got TuxedoInteractionSpec");
                  ixspec.setFunctionName(tmServiceName);
                  ixspec.setInteractionVerb(InteractionSpec.SYNC_SEND_RECEIVE);
          
          
                  logger.info("create Buffers");
                  inRec = new TuxedoStringRecord();
                  outRec = new TuxedoStringRecord();
                  logger.info("got Buffers");
                  inRec.setString(request);
                  logger.info("execute");
                  ix.execute(ixspec, inRec, outRec);
                  logger.info("execute ok");
          
          
                  logger.info("close Interaction");
                  ix.close();
                  logger.info("closed Interaction");
                  return outRec;
              }
              private ConnectionFactory getConnectionFactory() throws NamingException {
             // System.out.println("get ConnectionFactory");
                  if (connectionFactory == null) {
                      logger.info("ConnectionFactory nicht gesetzt, hole von "
                              + "Initial Context mit JNDI-Namen " + jndiName);
                      Context ctx = new InitialContext();
                      connectionFactory = (ConnectionFactory) ctx.lookup(jndiName);
                  }
                  return connectionFactory;
              }