Consultor Eletrônico



Kbase P124930: How to monitor the JMS MESSAGE COUNT in ABL for the SonicMQ adapter
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   16/07/2007
Status: Unverified

GOAL:

How to monitor the JMS MESSAGE COUNT

GOAL:

How to avoid exceeding the maximum number of messages

GOAL:

Code example for monitoring the MESSAGE COUNT before JMS-MAXIMUM-MESSAGES is reached

FACT(s) (Environment):

OpenEdge 10.x

FIX:

The variable definitions are:
DEFINE NEW GLOBAL SHARED VARIABLE JMS-MAXIMUM-MESSAGES AS INT.
DEFINE NEW GLOBAL SHARED VARIABLE PRGRS-JMS-MESSAGE-COUNT AS INT.

Code example:
DEFINE NEW GLOBAL SHARED VARIABLE JMS-MAXIMUM-MESSAGES AS INT INITIAL 50.
DEFINE NEW GLOBAL SHARED VARIABLE PRGRS-JMS-MESSAGE-COUNT AS INT.
DEFINE VARIABLE hSession AS HANDLE.
DEFINE VARIABLE messageH AS HANDLE.
JMS-MAXIMUM-MESSAGES = 2 .

RUN jms/jmssession.p PERSISTENT SET hSession ("-SMQConnect").
RUN setBrokerURL IN hSession ("localhost:2506").
RUN SETUSER IN hSession ("Administrator").
RUN setPassword IN hSession("Administrator").

RUN beginSession IN hSession NO-ERROR.
IF ERROR-STATUS:ERROR THEN
DO:
MESSAGE "Unable to access Sonic at this time, " +
"please verify Sonic Broker is available"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
IF VALID-HANDLE (hSession) THEN
DELETE PROCEDURE hSession.

END.
ELSE MESSAGE "Connected to SonicMQ" VIEW-AS ALERT-BOX.
RUN createTextMessage IN hSession (OUTPUT messageH) NO-ERROR.
RUN setText IN messageH ("Golf shoes on sale today").
/* Publish the message on the "GolfTopic" topic */
RUN publish IN hSession ("GolfTopic", messageH, ?, ?, ?).
IF (PRGRS-JMS-MESSAGE-COUNT) >= (JMS-MAXIMUM-MESSAGES ) THEN DO:
MESSAGE "Message Count Maximum : " JMS-MAXIMUM-MESSAGES ", Current : " PRGRS-JMS-MESSAGE-COUNT
", Do want to delete the message?"
VIEW-AS ALERT-BOX QUESTION BUTTONS YES-NO-CANCEL
TITLE "" UPDATE choice AS LOGICAL.
IF choice THEN RUN deleteMessage IN messageH.
END.

RUN createTextMessage IN hSession (OUTPUT messageH) .
RUN setText IN messageH ("Football shoes on sale today").

/* Publish the message on the "GolfTopic" topic */
RUN publish IN hSession ("GolfTopic", messageH, ?, ?, ?).
MESSAGE "Maximum: " JMS-MAXIMUM-MESSAGES VIEW-AS ALERT-BOX.
MESSAGE "Current: " PRGRS-JMS-MESSAGE-COUNT VIEW-AS ALERT-BOX.
RUN deleteMessage IN messageH.
MESSAGE "Current: " PRGRS-JMS-MESSAGE-COUNT VIEW-AS ALERT-BOX.
RUN deleteMessage IN messageH NO-ERROR.
MESSAGE "Current after 2. delete: " PRGRS-JMS-MESSAGE-COUNT VIEW-AS ALERT-BOX.
RUN deleteSession IN hSession.