Salesforce

4GL sample code to run a procedure asynchronously on an AppServer

« Go Back

Information

 
Title4GL sample code to run a procedure asynchronously on an AppServer
URL NameP10585
Article Number000140145
EnvironmentProduct: OpenEdge
Version: All supported versions
OS: All supported platforms
Question/Problem Description
4GL sample code to run a procedure asynchronously on an AppServer.
ABL sample code to run a procedure asynchronously on an AppServer.
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
The following sample code shows how to run a procedure asynchronously on an AppServer:

ABL client
/* client.p */
DEFINE VARIABLE cCustomer AS CHARACTER NO-UNDO INITIAL "Lift Tours".
DEFINE VARIABLE hRequest  AS HANDLE    NO-UNDO.
DEFINE VARIABLE hServer   AS HANDLE    NO-UNDO.
DEFINE VARIABLE lReturn   AS LOGICAL NO-UNDO.

CREATE SERVER hServer.
lReturn = hServer:CONNECT("-URL http://MyHostname/inventory/apsv").

RUN server.p ON hServer ASYNCHRONOUS SET hRequest
   EVENT-PROCEDURE "GetCustNum"
   (INPUT cCustomer, OUTPUT iCustomer AS INTEGER).

MESSAGE "Amount of outstanding asynchronous requests: " hRequest:ASYNC-REQUEST-COUNT
   VIEW-AS ALERT-BOX.

WAIT-FOR PROCEDURE-COMPLETE OF hRequest.

MESSAGE "Amount of outstanding asynchronous requests: " hRequest:ASYNC-REQUEST-COUNT
VIEW-AS ALERT-BOX.

DELETE OBJECT hRequest NO-ERROR.
hServer:DISCONNECT().
DELETE OBJECT hServer NO-ERROR.


PROCEDURE GetCustNum:
DEFINE INPUT PARAMETER piCustomer AS INTEGER NO-UNDO.

   IF hServer:ERROR OR hServer:STOP THEN
      MESSAGE "An error occurred while retrieving the customer number for " cCustomer "." SKIP
              "The error is: " ERROR-STATUS:GET-MESSAGE(1)
                 VIEW-AS ALERT-BOX.
   ELSE
      MESSAGE "The customer number for " cCustomer " is: " piCustomer
         VIEW-AS ALERT-BOX.

END.


AppServer
/* server.p */
DEFINE INPUT  PARAMETER pcCustomer AS CHARACTER NO-UNDO.
DEFINE OUTPUT PARAMETER piCustomer AS INTEGER   NO-UNDO.

/* Requires a connection to the Sports2000 database from PASOE or Classic AppServer */
FOR FIRST customer WHERE customer.name = pcCustomer NO-LOCK:
  piCustomer = customer.custnum.
END.

Note
When an asynchronous request completes execution on the server, it sends a response to the client, which places it on the response queue for the appropriate server handle. To signify that the response is ready to be processed, the PROCEDURE-COMPLETE event is placed on the event queue where it can be processed in the context of blocking I/O statements, such as WAIT-FOR or the PROCESS EVENTS statement.
Workaround
Notes
References to Other Documentation:

Application Development with PAS for OpenEdge, Managing asynchronous requests:
https://docs.progress.com/bundle/pas-for-openedge-develop-applications-122/page/Managing-asynchronous-requests.html

OpenEdge Application Server: Developing AppServer Applications, Understanding synchronous and asynchronous requests:
https://docs.progress.com/bundle/openedge-classic-appserver-development-117/page/Understanding-synchronous-and-asynchronous-requests.html

Progress Article(s):  
How to use parameters in Asynchronous Requests
 
Keyword Phrase
Last Modified Date6/30/2023 11:12 AM

Powered by