Natural RPC on the mainframe does not presently have the load balancing features of the EntireX RPC Servers. To approximate this, you need to be able to shut down the Natural RPC server on timeout (00740074). The other half of the solution is to use EntireX Attach Manager or custom Attach Services (ACI) calls to start the servers on demand.
A suggestion on how to implement server shutdown with Natural RPC Servers on the mainframe was to use the exit NATRPC39.
With some experimenting, I was able to get a Natural RPC server to shut down on timeout.
I started with modifying NATRPC39 exit to just call USR2073N to shutdown the currently running thread. USR2073N is available in SYSEXT in Natural 4 and is in Natural 3.1.6 (doesn?t show up in the documented list in 316, but is there). It allows you to PING or TERMINATE an RPC server. Each call to the TERMINATE will shut down one server thread (if you are using NTASKS, each task is a thread)
There were complications…
- the call to USR2073N is calling the server itself and the call to NATRPC39 blocks the thread. It works, but it takes a while as everything has to time out before it notices that it needs to shut down.
- The documentation doesn?t actually mention when NATRPC39 gets called. SL24 logs indicated that it was on timeouts (00740074). Other logs indicated issues with NAT3009 if the server was busy and didn?t call all of its databases regularly. So, it appears that somewhere along the line, NATRPC39 has been changed to be called on every server return.
- A shutdown call was a server return, triggering NATRPC39 also, so if I had NTASKS, they were all shut down the first time NATRPC39 was called. Thus, on the first successful call or timeout, all server threads shut down.
The workarounds:
- CMTASK is called from NATRPC39 to get around the blocked thread. This starts another Natural thread (like an NTASK) and executes a program that calls USR2073N. It must have RPC=(SERVER=OFF) in its parms, or the start of another thread causes it to start the RPC server again (parameters are merged with the CMPRMIN parameters). My ?NATRPC39? reassigns CMPRINT to ?RPCPRT01? when it starts a task. This is optional. If used, you need to add ?//RPCPRT01 DD SYSOUT=*? to your RPC server JCL.
- RPCINFO returns information about the server parms and, most importantly, the last RPC error received. With this, I can check for 00740074 before doing the shutdown request.
- NATRPC39 needs to be in SYSTEM (FUSER). Not SYSRPC and not the user library. And if you have it in SYSLIB, take it out.
- Copy RPCINFO, USR2073N to SYSTEM. They are needed by this NATRPC39.
- NATRPC39 sets up the stack to call program ?RPCTERM? in my library (YSARKE). This could go anywhere.
- The enclosed code assumes a Natural Security environment with the RPC server running with LOGONRQ=ON.
Included is:
- NATRPC39. Copy to SYSTEM. It uses CMTASK to start another thread. You will need to modify it to your environment - change the NATPGM and the logon STACK.
- RPCTERM that is called by from the started thread.
Douglas Kelly,
Principal Consultant
Software AG, Inc
Sacramento, California
natrpc39.systrans (4.85 KB)