Kbase 19433: APPSERVER - How ASYNC-REQUEST-COUNT Works
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  19/01/2000 |
|
In Version 9.1A and higher we provide the ability to invoke asynchronous requests against an AppServer.
One of the attributes available in the asynchronous world is the
ASYNC-REQUEST-COUNT attribute. This attribute allows you to to determine how many outstanding requests are pending against both an AppServer connection and any persistent procedures that are running on the AppServer. When used against an AppServer connection handle this attribute returns the number of outstanding requests. When used against a persistent procedure handle it returns the number of outstanding requests for that handle.
It is important to note that this value is decremented as part of the processing of the PROCEDURE-COMPLETE event and this occurs before the event procedure is called (so, in essence, this value is always the number of requests that are queued + the executing request (if any)).
The following code gives an example of this attribute in action (the code that runs on the AppServer is listed first followed by the code that runs on the client):
This code will return message boxes with the following values:
Request hProc1 Count hProc2 Count hServer Count
------- ------------ ------------ -------------
1 4 5 9
2 4 4 8
3 3 4 7
4 3 3 6
5 2 3 5
6 2 2 4
7 1 2 3
8 1 1 2
9 0 1 1
10 0 0 0
/**
** Program Name: ServerTest02.p
** Description : Used To Test The ASYNC-REQUEST-COUNT Attribute
**/
PROCEDURE TheBigPause:
DEFINE INPUT PARAMETER iPause AS INTEGER NO-UNDO.
DEFINE OUTPUT PARAMETER cTime AS CHARACTER NO-UNDO.
PAUSE iPause NO-MESSAGE.
ASSIGN cTime = STRING(TIME,"HH:MM:SS").
END PROCEDURE.
/**
** Program Name: AsyncClientTest02.p
** Description : Used To Call The AppServer & Test The
** ASYNC-REQUEST-COUNT Attribute
**/
DEFINE VARIABLE hServer AS HANDLE NO-UNDO.
DEFINE VARIABLE hProc1 AS HANDLE NO-UNDO.
DEFINE VARIABLE hProc2 AS HANDLE NO-UNDO.
DEFINE VARIABLE hAsync AS HANDLE NO-UNDO.
DEFINE VARIABLE lRet AS LOGICAL NO-UNDO.
DEFINE VARIABLE iLoop AS INTEGER NO-UNDO.
DEFINE VARIABLE cData AS CHARACTER NO-UNDO.
CREATE SERVER hServer.
lRet = hServer:CONNECT("-AppService X -H Y -S 5162", "", "") NO-ERROR.
IF lRet = FALSE THEN
DO:
MESSAGE "Connection Failed" VIEW-AS ALERT-BOX.
RETURN.
END.
RUN ServerTest02.p PERSISTENT SET hProc1
ON hServer TRANSACTION DISTINCT.
RUN ServerTest02.p PERSISTENT SET hProc2
ON hServer TRANSACTION DISTINCT.
DO iLoop = 1 TO 5:
RUN TheBigPause IN hProc1 ASYNCHRONOUS SET hAsync
EVENT-PROCEDURE "CallCompleted" ((7 - iLoop), OUTPUT cData).
RUN TheBigPause IN hProc2 ASYNCHRONOUS SET hAsync
EVENT-PROCEDURE "CallCompleted" ((7 - iLoop), OUTPUT cData).
END.
MESSAGE "Finished Sending Async Requests" SKIP
"Requests Queued = " + STRING(hServer:ASYNC-REQUEST-COUNT)
VIEW-AS ALERT-BOX.
WAIT-FOR END-ERROR OF THIS-PROCEDURE.
DELETE PROCEDURE hProc1.
DELETE PROCEDURE hProc2.
hServer:DISCONNECT().
DELETE OBJECT hServer.
PROCEDURE CallCompleted:
DEFINE INPUT PARAMETER cTime AS CHARACTER NO-UNDO.
MESSAGE "cTime = " + cTime SKIP
STRING(hProc1:ASYNC-REQUEST-COUNT) SKIP
STRING(hProc2:ASYNC-REQUEST-COUNT) SKIP
STRING(hServer:ASYNC-REQUEST-COUNT) VIEW-AS ALERT-BOX.
END PROCEDURE.