Consultor Eletrônico



Kbase 19474: APPSERVER - How CANCEL-REQUESTS() Works
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   02/02/2000
In Version 9.1A and higher we provide the ability to invoke asynchronous requests against an AppServer.

One of the methodss available in the asynchronous world is the
CANCEL-REQUESTS() method. This method forwards a 4GL "STOP" condition to the currently executing request on the AppServer and purges all other pending requests before they ever reach the AppServer.

When using this method it is important that your evvent-procedures test both the CANCELLED and STOP attributes.

The following code gives an example of this method 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 Cancelled Attribute Stop Attribute
------- ------------------- --------------
1 FALSE TRUE
2 TRUE FALSE
3 TRUE FALSE
4 TRUE FALSE


/**
** Program Name: ServerTest04.p
** Description : Used To Test The CANCEL-REQUESTS() Method
**/

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: AsyncClientTest04.p
** Description : Used To Call The AppServer & Test The
** CANCEL-REQUESTS() Method
**/

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 ServerTest03.p PERSISTENT SET hProc1
ON hServer TRANSACTION DISTINCT.

RUN ServerTest03.p PERSISTENT SET hProc2
ON hServer TRANSACTION DISTINCT.

DO iLoop = 1 TO 2:
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.

/**
** Four requests were queued for execution on the AppServer. We
** are going to "blow 'em all out of the water" now.
**/

hServer:CANCEL-REQUESTS().

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 "CANCELLED = " SELF:CANCELLED
", STOP = " SELF:STOP VIEW-AS ALERT-BOX.
END PROCEDURE.