A distributed application consists of a set of software modules that reside on multiple hardware systems, and that communicate with one another to accomplish the tasks required of the application. For example, as shown in Figure 1‑1, a distributed application for a remote online banking system includes software modules that run on a bank customer’s home computer, and a computer system at the bank on which all bank account records are maintained.The Oracle Tuxedo distributed application programming environment provides the API functions necessary to enable secure, reliable communication between the distributed software modules. This API is referred to as the Application-to-Transaction Monitor Interface (ATMI).Table 1‑1 describes the Oracle Tuxedo ATMI communication paradigms available to application developers.
Table 1‑1 Communication Paradigms Refer to “Writing Request/Response Clients and Servers” on page 6‑1 for more information on this paradigm. Refer to “Writing Conversational Clients and Servers” on page 7‑1 for more information on this paradigm. Refer to Using the ATMI /Q Component for more information on the /Q facility. Refer to “Writing Event-based Clients and Servers” on page 8‑1 for more information on this paradigm.An Oracle Tuxedo ATMI client is a software module that collects a user request and forwards it to a server that offers the requested service. Almost any software module can become an Oracle Tuxedo client by calling the ATMI client initialization routine and “joining” the Oracle Tuxedo application. The client can then allocate message buffers and exchange information with the server.The client calls the ATMI termination routine to “leave” the application and notify the Oracle Tuxedo system that it (the client) no longer needs to be tracked. Consequently, Oracle Tuxedo application resources are made available for other operations.Listing 1‑1 Pseudo-code for a Request/Response Clientmain()
{
allocate a TPINIT buffer
place initial client identification in buffer
enroll as a client of the BEA Tuxedo application
allocate buffer
do while true {
place user input in buffer
send service request
receive reply
pass reply to the user }
leave application
}Most of the actions described in the above listing are implemented with ATMI functions. Others—placing the user input in a buffer and passing the reply to the user—are implemented with C language functions.During the “allocate buffer” phase, the client program allocates a memory area, called a typed buffer, from the Oracle Tuxedo run-time system. A typed buffer is simply a memory buffer with an associated format, for example, a C structure.Before you can execute an ATMI client, you must run the buildclient command to compile it and link it with the Oracle Tuxedo ATMI and required libraries. Refer to “Writing Clients” on page 4‑1 for information on the buildclient command.An Oracle Tuxedo ATMI server is a process that provides one or more services to a client. A service is a specific business task that a client may need to perform. Servers receive requests from clients and dispatch them to the appropriate service subroutines.To build server processes, applications combine their service subroutines with a main() process provided by the Oracle Tuxedo system. This system-supplied main() is a set of predefined functions. It performs server initialization and termination and allocates buffers that can be used to receive and dispatch incoming requests to service routines. All of this processing is transparent to the application.Figure 1‑2 summarizes, in pseudo-code, the interaction between a server and a service subroutine.The conversational paradigm is somewhat different from request/response, as illustrated by the pseudo-code in Figure 1‑3.The Oracle Tuxedo system-supplied main() process contains the code needed to enroll a process as an ATMI server, advertise services, allocate buffers, and dequeue requests. ATMI functions are used in service subroutines that process requests. When you are ready to compile and test your service subroutines, you must link edit them with the server main() and generate an executable server. To do so, run the buildserver command.If a client requests several services, or several iterations of the same service, a subset of the services might be transferred to another server for execution. In this case, the server assumes the role of a client, or requester. Both clients and servers can be requesters; a client, however, can only be a requester. This coding model is easily accomplished using the Oracle Tuxedo ATMI functions.The ATMI is a reasonably compact set of functions used to open and close resources, begin and end transactions, allocate and free buffers, and support communication between clients and servers. Table 1‑2 summarizes the ATMI functions. Each function is described in the Oracle Tuxedo ATMI C Function Reference.
Table 1‑2 Using the ATMI Function