Kbase 21689: Error Handling: SonicMQ Adapter down.
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  11/25/2008 |
|
Status: Verified
GOAL:
How to trap for a SonicMQ Adapter down situation?
FACT(s) (Environment):
Progress 9.1x
OpenEdge 10.x
FIX:
This example code will handle a SonicMQ Adapter down situation giving the programmer ability to trap for this condition.
/* Receives a Text message from a queue. */
DEFINE VARIABLE ptpsession AS HANDLE.
DEFINE VARIABLE consumerH AS HANDLE.
DEFINE VARIABLE UniqueMessage AS INTEGER.
DEFINE VARIABLE counter AS INTEGER.
DEF VAR l-started AS LOGICAL.
/* Creates a session object. */
RUN jms/ptpsession.p PERSISTENT SET ptpsession ("-H localhost -S 5162 ").
RUN setBrokerURL IN ptpsession ("localhost:2506").
RUN setUser IN ptpsession("Username").
RUN setPassword IN ptpsession("Password").
run setnoerrorDisplay IN ptpsession("True").
RUN beginSession IN ptpsession.
/* GolfQueue Messages are handled by the "golfHandler" procedure. */
RUN createMessageConsumer IN ptpsession (
THIS-PROCEDURE,
"golfHandler",
OUTPUT consumerH).
RUN receiveFromQueue IN ptpsession ("test",
?,
consumerH).
/* Start receiving messages */
RUN startReceiveMessages IN ptpsession.
/* Wait to receive the messages. Any other IO-blocked statements can be
used for receiving messages. */
l-started = YES.
REPEAT:
DO WHILE l-started ON STOP UNDO, LEAVE:
WAIT-FOR u1 OF THIS-PROCEDURE.
END. /* WHILE l-started */
IF error-status:ERROR THEN
DO:
MESSAGE "Raising STOP condition" VIEW-AS ALERT-BOX.
MESSAGE " run logic to handle adapter down" VIEW-AS ALERT-BOX.
END.
END.
PROCEDURE golfHandler:
DEFINE INPUT PARAMETER messageH AS HANDLE.
DEFINE INPUT PARAMETER msgConsumerH AS HANDLE.
DEFINE OUTPUT PARAMETER replyH AS HANDLE.
/* Display the message - we assume that reply is not required. */
MESSAGE DYNAMIC-FUNCTION('getjmsmessageid':U IN messageH).
RUN deleteMessage IN messageH.
END.
APPLY "U1" TO THIS-PROCEDURE.