Developing Tuxedo Servers with SALT and SCA
By Todd Little on Feb 04, 2009
Technical APIs are those APIs that access infrastructure or system functions that are not directly related to the business functions the application provides. Thus APIs that allocate messages, populate messages, send and receive messages, invoke services, etc., are all technical APIs. While not bad in and of themselves, technical APIs can get in the way of programmer productivity.
The SCA Client and Implementation standard defines how a particular programming language should provide SCA capabilities. In the case of C++ it defines the classes and methods that need to be provided by an SCA runtime that supports SCA clients and servers written in C++. This blog entry will show how a Tuxedo ATMI server and an SALT SCA based server are written. To keep the business logic to a minimum and pick a subject area familiar to all I'll use a simple 4 function calculator.
ATMI ServersIn an ATMI server, the developer creates services as C functions. The function is dispatched automatically by Tuxedo, whether in a single thread or in a worker thread for multi-threaded servers. The function receives as an argument a structure that contains such information as the name of the service, some flags, and a pointer to the message sent by the client. The function then extracts the information sent by the client from the message, performs whatever business function needs to be performed, creates and populates a return message, and then returns that message to the client. Here is an ATMI server that implements for services, ADD, SUBTRACT, MULTIPLY, and DIVIDE.
ATMI Calculator Server
Each service implementation uses the the FML32 functions to extract the incoming fields from the message sent by the client, then performs the simply business logic of a calculator. Finally it modifies the original message to remove the input fields, add the result field, and returns that to the client.
SCA ServersSCA servers in SALT 10gR3 have all of their message handling performed by the SCA container and generated code. These pieces accept a message, extract the appropriate fields, then call a C++ method to perform the business logic. The method simply returns the result to the SCA runtime which in turn creates a reply message and returns that to the client. With the ATMI Binding Extension provided by SALT, a normal ATMI buffer is used to hold the request and reply messages which allows interoperability with ATMI clients and server. Here is an example of a 4 function calculator server written using the SCA container.
SCA Calculator Server
As you can see, there is considerably less code to write for an SCA based server. As well the code is all pure C++ code without any technical or middleware APIs used. This same code could be used in many ways, not just within the context of an SCA service implementation.
Hopefully these two simple examples illustrate some of the benefits of using SCA to implement services. In my next entry, I'll show how this same 4 function calculate can be accessed as a web service and how SALT help makes this a trivial exercise requiring no code changes to either the ATMI server or the SCA server.