One of the 187 new features in Tuxedo 12c is the
ability to develop Tuxedo services in Java. Prior to Tuxedo 12c, to
create a Tuxedo service in Java meant adding another application server such as
WebLogic Server or IBM WebSphere to the environment and using either the
WebLogic Tuxedo Connector (WTC) or the Tuxedo JCA Adapter. The service
was then developed in Java, deployed to the Java EE application server, and
then connected to existing Tuxedo applications via the Tuxedo domain
gateway. This meant that every request from Tuxedo to these Java services
entailed a network hop and any distributed transactions required a subordinate
transaction to be started in the Java EE application server. As well, any
native Tuxedo service called by the Java service now required another network
hop--all in all usable, but requiring more administration, more resources, and
more complexity.
Java Server Support
The Java Server support in Tuxedo uses a POJO programming model based upon Java
SE. The programming environment and APIs used for service development is
JATMI, the same API used in WTC. JATMI is essentially an object oriented
version of the standard Tuxedo Application to Transaction Monitor Interface
(ATMI). It supports virtually all of the ATMI features and should be very
familiar to anyone that has developed Tuxedo services in another
language. Yet being Java developers have access to the rich set of class
libraries that Java developers have come to know and love. Since the
environment is Java SE based, Java EE features such as transaction management
are provided by the JATMI classes instead of the Java Transaction API.
Developing & Deploying Java Service on Tuxedo is easy
Developing and deploying services in Java on Tuxedo is extremely easy and
straightforward. The basic steps are to create a Java class that extends
the TuxedoJavaServer class provided by JATMI. Create one or more methods
that will handle Tuxedo service requests. These methods take a TPSVCINFO
instance as the only parameter that contains such information as the name of
the service called and the typed buffer the caller passed to the service.
The method extracts whatever information it needs from the typed buffer,
performs its business logic and then creates a typed buffer to reply to the
caller. Finally the class calls the tpreturn() method to return the reply
buffer back to the caller.
Configuring the Tuxedo Java Server
Once the server class or classes have been developed and compiled, the Tuxedo Java Server TMJAVASVR needs to be added to the Tuxedo UBBCONFIG file. This Tuxedo provided server will load the JVM, load the server classes, and take care of dispatching incoming requests to the methods in the server classes. Which classes to load and the mapping between Tuxedo service names that the server will offer are defined in an XML based configuration file. By default each public method in the server classes is advertised as the name of the Tuxedo service. This configuration file also specifies such things as the classpaths to be used, JDBC driver and connection information for accessing a database, and resources such as FML/FML32 field tables and VIEW/VIEW32 classes. After updating and loading the UBBCONFIG file, the application is ready to be booted and tested.
Sample Implementation and Configuration
Here is what a simple Java service implementation might look like:
public void JAVATOUPPER(TPSVCINFO rqst) throws
TuxException {
TuxAppContext myAppCtxt =
getTuxAppContext(); /* The the
application context */
TypedBuffer svcData =
rqst.getServiceData(); /* Get the callers
data */
TypedString TbString =
(TypedString)svcData; /* Assume it's a
STRING buffer */
String newStr =
TbString.toString().toUpperCase(); /* Get the string and
upper case it */
TypedString replyTbString = new
TypedString(newStr); /* Create the reply buffer */
myAppCtxt.tpreturn(TPSUCCESS, 0,
replyTbString, 0); /* Return reply buffer to caller */
}
The entry in the UBBCONFIG for the Tuxedo Java Server might look like:
TMJAVASVR
SRVGRP=GROUP1 SRVID=2 CLOPT="-A"
CLOPT="-- -c
TJSconfig.xml"
MINDISPATCHTHREADS=2
MAXDISPATCHTHREADS=10
which would start a single copy of the Tuxedo Java Server with 10 threads to handle requests. The configuration file TJSconfig.xml for this server might look something like:
<?xml
version="1.0" encoding="UTF-8"?>
<TJSconfig>
<TuxedoServerClasses>
<TuxedoServerClass
name="MyTuxedoJavaServer"></TuxedoServerClass>
</TuxedoServerClasses>
</TJSconfig>
where MyTuxedoJavaServer is the name of the Java class that extends the TuxedoJavaServer class.Multiple copies of the
Tuxedo Java Server can be run just as any other Tuxedo server using the same
configuration file or each using their own configuration file. All
standard Tuxedo buffer types are supported, so services can use STRING, CARRAY,
MBSTRING, FML/FML32, XML, or VIEW/VIEW32 buffers. As well, Java services
can call other Tuxedo services by using the tpcall() method on the
TuxAppContext.
Summary
As the Tuxedo Java Server is a standard Tuxedo server, all of the monitoring, management, and administration capabilities that Tuxedo provides to C or other language servers is available to services written in Java. These services also benefit from the unmatched reliability, availability, scalability, and performance that Tuxedo has proven to provide at thousands of customer sites. By providing Java support in Tuxedo, customers are free to choose the language that best suits their application development needs, whether it is C, C++, COBOL, Python, Ruby, PHP, and now Java, and they all work together seamlessly to provide one integration application.
Stay Connected
Tuxedo:
Cloud Application Foundation (CAF):