Salesforce

How to determine which persistent procedures are currently running.

« Go Back

Information

 
TitleHow to determine which persistent procedures are currently running.
URL NameP15973
Article Number000138310
EnvironmentProduct: Progress
Version: 9.x
Product: OpenEdge
Version: 10.x, 11.x, 12.x
OS: All Supported Operating Systems
Question/Problem Description
How to determine which persistent procedures are currently running.
How to determine which persistent procedures are currently running on a client.
How to determine which persistent procedures are currently running on an AppServer.
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
There are 3 categories of persistent procedures to consider:
1. Running locally to the client: These can be found by following the chain starting from SESSION:FIRST-PROCEDURE.
2. Started from client, running on the AppServer: These can be found by following the chain starting from <server handle>:FIRST-PROCEDURE.
3. Running locally on the AppServer agents, without the client being aware: These are also found by following the chain starting from SESSION:FIRST-PROCEDURE, but the code must be running on the AppServer agent.


The following program demonstrates how to report the persistent procedures for both the client session and the AppServer session:
/*
File        : ReportPersistentProcs.p
Purpose     : Example code to report the persistent procedures running in an AVM.
Notes       : This is written so it can also be deployed on the AppServer and be
              called from a client process.
*/

/* Variable definitions                                                 */
DEFINE VARIABLE hServer      AS HANDLE     NO-UNDO.
DEFINE VARIABLE hProcedure   AS HANDLE     NO-UNDO.
DEFINE OUTPUT PARAMETER  cClientProcs  AS CHARACTER  NO-UNDO.
DEFINE OUTPUT PARAMETER  cServerProcs AS CHARACTER  NO-UNDO.


/* Get all persistent procedures running locally (SESSION handle)    */
hProcedure = SESSION:FIRST-PROCEDURE.
DO WHILE VALID-HANDLE(hProcedure):
  cClientProcs = cClientProcs + hProcedure:FILE-NAME + ",".
  hProcedure = hProcedure:NEXT-SIBLING.
END.

/* 
Get all persistent procedures started from client, running on AppServers (Server Object handles).
Take into account that a client can have connections to multiple servers at the same time.
*/
hServer = SESSION:FIRST-SERVER.
DO WHILE VALID-HANDLE(hServer):
   cServerProcs = cServerProcs + hServer:NAME + " -> ":U.
   hProcedure = hServer:FIRST-PROCEDURE.
   
   DO WHILE VALID-HANDLE(hProcedure):
     cServerProcs = cServerProcs + hProcedure:FILE-NAME + ",":U.
     hProcedure = hProcedure:NEXT-SIBLING.
   END.
   cServerProcs = TRIM(cServerProcs,",":U) + CHR(10). 
   hServer = hServer:NEXT-SIBLING.
END.

/* Clean up and display the lists of procedures                         */
ASSIGN cClientProcs = TRIM(cClientProcs,",":U)
      cServerProcs = TRIM(cServerProcs,"|":U).

To invoke the report and show the results, use code similar to the following   
/*
File        : ShowPersistentProcs.p
Purpose     : Example code to show how to determine the persistent procedures
              running on an AppServer.
Notes       : It is assumed that dummy.p is available in the working directory of 
              the AppServer. Dummy.p can be an empty procedure file; no code is 
              invoked within the persistent procedures.
*/

DEFINE VARIABLE cClientProcs AS CHARACTER  NO-UNDO.
DEFINE VARIABLE cServerProcs AS CHARACTER  NO-UNDO.
DEFINE VARIABLE hServer        AS HANDLE     NO-UNDO.


/* Connect to AppServer on localhost (test environment)                  */
CREATE SERVER hServer.
hServer:CONNECT("-AppService asbroker1").

/* run the dummy procedure on the client times.                         */
RUN dummy.p PERSISTENT.

/* run the dummy procedure on the AppServer three times.                */
RUN dummy.p PERSISTENT ON hServer.
RUN dummy.p PERSISTENT ON hServer.
RUN dummy.p PERSISTENT ON hServer.


RUN ReportPersistentProcs.p (OUTPUT cClientProcs, OUTPUT cServerProcs). 
MESSAGE "Client-side procedures":U SKIP
"Persistent procs. on client: ":U + cClientProcs  SKIP 
"Persistent procs. on AppServers: " + cServerProcs    VIEW-AS ALERT-BOX INFO BUTTONS OK.

RUN ReportPersistentProcs.p ON hServer (OUTPUT cClientProcs, OUTPUT cServerProcs). 
MESSAGE "Server-side procedures":U SKIP
"Persistent procs. on agent: ":U + cClientProcs  SKIP 
"Persistent procs. on other AppServers: " + cServerProcs    VIEW-AS ALERT-BOX INFO BUTTONS OK.

hServer:DISCONNECT().

 
Workaround
Notes
References to Other Documentation:

ABL reference, Handle reference, Server Object Handle:
https://docs.progress.com/bundle/openedge-abl-reference-122/page/Server-object-handle.html

ABL reference, Handle reference, SESSION System Handle:
https://docs.progress.com/bundle/openedge-abl-reference-122/page/SESSION-system-handle.html

ABL reference, Handle attributes and methods reference, FIRST-PROCEDURE Attribute:
https://docs.progress.com/bundle/openedge-abl-reference-122/page/FIRST-PROCEDURE-attribute.html
Keyword Phrase
Last Modified Date8/24/2023 5:25 PM

Powered by