OpenTP1 Version 7 Programming Guide

[Contents][Index][Back][Next]

5.1.7 How to create server UAP

This subsection explains how to use a function from the service function (server UAP) for XATMI-interfaced communication. The creation method of server UAPs is different from that of the OpenTP1 service functions.

Organization of this subsection
(1) Coding service functions provided by server UAP
(2) Relationship between load-balancing types (on one node or multiple nodes) and tpunadvertise()

(1) Coding service functions provided by server UAP

When writing code in C for service functions, follow the format given for tpservice(). This format is a standard coding format.

If you are writing code in COBOL, invoke TPSVCSTART before using an XATMI-interfaced API for service program processing.

(a) How to terminate a service function

A service function terminates when the function tpreturn() [TPRETURN] is called. For XATMI-interfaced communication under OpenTP1, the function tpreturn() must be called immediately before the service function is terminated by return(). The result of any process performed after call of the function tpreturn() is unpredictable.

(b) Advertisement of a service name

The server UAP can declare that its own service name is ready to offer service (advertisement of a service name). To advertise a service name, call the function tpadvertise() [TPADVERTISE].

When the server UAP is activated, the service specified in the user service definition becomes advertised service. It is unnecessary to call the function tpadvertise() with the service name specified in the user service definition.

To unadvertise a service name, call the function tpunadvertise() [TPUNADVERTISE]. When the function tpunadvertise() is called, the service request for the service name returns with an error. A service name that once unadvertised by the function tpunadvertise() can accept a service request again if the function tpadvertise() is called.

The functions tpadvertise() and tpunadvertise() can be called only from SPPs. They cannot be called before the function dc_rpc_mainloop().

The function tpadvertise() has the function address to be advertised as its argument. This argument is used to check whether the service name can be advertised. Under OpenTP1, if the server using the function tpadvertise() has the same service group as the server advertising its service name, it is regarded as advertised and the function returns normally. If the service groups are different, the function tpadvertise() returns with an error.

(2) Relationship between load-balancing types (on one node or multiple nodes) and tpunadvertise()

(a) Load balancing at only one node (multiserver facility)

If the function tpunadvertise() is called from a process when load balancing is effective at one node (multiserver facility), all processes on which load is distributed become unable to receive service. Then, the function tpadvertise() is called to advertise the service, the processes become ready to accept a service request.

The multiserver facility is available only for queue-receiving servers (SPPs scheduled by schedule service). Servers that receive requests from socket cannot use the multiserver facility.

(b) Load balancing at multiple nodes (internode load-balancing facility and extended internode load-balancing facility)

Suppose that load balancing (internode load-balancing facility and extended internode load-balancing facility) is effective at multiple nodes and the function tpunadvertise() is called from a process. At the node of the process that called the function tpunadvertise(), service stops. However, the service request can be accepted by a server at another node. Under this environment, the function tpadvertise() is called to advertise the service, the process becomes ready for accepting service request.

The internode load-balancing facility can be used by either the queue or server that receives requests from socket. The extended internode load-balancing facility can only be used for queue-receiving servers.