Three program units, namely UPDIAL, UPASYN and UPDGET, are supplied with openUTM for asynchronous processing with UPIC clients.
Functions
These three program units illustrate how to issue asynchronous requests from a UPIC client and how to receive asynchronous result information.
In this example, the asynchronous message is first sent to the USER queue of the user ID under which the UPIC client signed on. The message is then read by an interactive program unit and output on the client. The advantage of asynchronous processing is that the user at the UPIC client can enter a new request as soon as the current request is accepted and is not blocked until the request is completed.
These three programs have the following functions:
UPDIAL reads an input message, sends it to the UPASYN program unit as an asynchronous request, and outputs a request confirmation on the client.
UPASYN receives the message, waits 5 seconds to simulate complex processing, and writes the result in the USER queue of the user ID under which the UPIC client signed on.
UPDGET waits (60 seconds) and reads the user ID of the service (if the dialog message is empty) or the user ID passed in the dialog message from the USER queue. This means that the UPDGET can run under a different user ID (e.g. without using a security user) from the UPDIAL and UPASYN services and fetch the message from the user queue of the user that started the UPDIAL service.
If a dialog message that is not empty does not contain a valid user ID, UPDGET terminates with an error message. If no queue message is available, UPDGET is started again as soon as a message arrives or when the wait time has elapsed. If a queue message is available, it is sent to the UPIC client with MPUT and its own TAC is called again with PEND-RE in order to wait for the next message.
Components
The source programs and object modules are supplied as elements of the SYSLIB.UTM.070.EXAMPLE library. The sample programs should only be run in conjunction with a UPIC client program adjusted appropriately.
Integration in a UTM application
If the client is only to run with users generated with RESTART=NO, the procedure is as follows:
The UPIC client maintains two connections to the UTM application and signs on with the same user ID for openUTM. In the first thread, the client starts the interactive service UPDGET to read the asynchronous messages. In the second thread, the client starts the interactive service UPDIAL on explicit request, which then generates an asynchronous request for UPASYN.
If the client is also to run with users generated with RESTART=YES, the following procedure is possible:
The client only signs on as a security user in the second thread, and in the first thread signs on without explicitly specifying a security user. openUTM therefore allocates it a user permanently assigned to the connection. The first thread then also returns the name of the security user in the dialog message when UPDGET is started (and at every step in the dialog).