Consultor Eletrônico



Kbase P185447: How can I detect if database is not connected in AppServer activate procedure and terminate the agen
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   06/04/2011
Status: Unverified

GOAL:

How can I detect if database is not connected in AppServer activate procedure and terminate the agent?

GOAL:

Is it possible to terminate an AppServer agent programmatically?

FACT(s) (Environment):

Windows
OpenEdge 10.x

FIX:

The following code shows how to detect (during the AppServer activate procedure) that the application databases are no longer connected and to then force the termination of the AppServer agent (the client will detect the situation and attempt a reconnect which will start another AppServer agent):

PROCEDURE ExitProcess EXTERNAL "kernel32":
DEFINE INPUT PARAMETER piExitCode AS LONG NO-UNDO.
END PROCEDURE.

DEFINE VARIABLE iLoop AS INTEGER NO-UNDO.
DEFINE VARIABLE iNumDatabases AS INTEGER NO-UNDO.

ASSIGN iNumDatabases = NUM-DBS.

IF iNumDatabases = 0 THEN
RUN ExitProcess(0).
ELSE
DO iLoop = iNumDatabases TO 1 BY -1 ON STOP UNDO, RETRY ON ERROR UNDO, RETRY:
IF RETRY THEN
RUN ExitProcess(0).

IF NOT CONNECTED(LDBNAME(iLoop)) THEN
UNDO, RETRY.
END.