DEFINE VARIABLE hSession AS HANDLE NO-UNDO.
DEFINE VARIABLE rejectedMsgH AS HANDLE NO-UNDO. /* Run adapter as symbiotic process */ RUN jms/jmssession.p PERSISTENT SET hSession ("-SMQConnect"). /* Set local store directory off of current working directory */ RUN setLocalStoreDirectory IN hSession ("mqstore"). RUN setLocalStoreSize IN hSession (5000). /* Set timeouts - Retry every 5 minutes and give up if broker down 10 hours */ RUN setReconnectTimeout IN hSession (600). RUN setReconnectInterval IN hSession (300). RUN setClientPersistence IN hSession (TRUE). RUN setBrokerURL IN hSession ("MQBrokerHost:2506"). RUN setClientID IN hSession ("SomeUniqueName"). RUN beginSession IN hSession. /* Once session is established, create rejected Message Consumer */ RUN createRejectedMessageConsumer IN hSession (THIS-PROCEDURE, "RejectedMsgHandler", OUTPUT rejectedMsgH). PROCEDURE RejectedMsgHandler: DEFINE INPUT PARAMETER hMessage AS HANDLE NO-UNDO. DEFINE INPUT PARAMETER hMessageConsumer AS HANDLE NO-UNDO. /* hAutoReply is not used in this example */ DEFINE OUTPUT PARAMETER hAutoReply AS HANDLE NO-UNDO. DEFINE VARIABLE contentType AS CHARACTER NO-UNDO. DEFINE VARIABLE errorCode AS CHARACTER NO-UNDO. DEFINE VARIABLE errorText AS CHARACTER NO-UNDO. DEFINE VARIABLE exceptionCode AS CHARACTER NO-UNDO. DEFINE VARIABLE hMessagePart AS HANDLE NO-UNDO. DEFINE VARIABLE iNumParts AS INTEGER NO-UNDO. DEFINE VARIABLE msgType AS CHARACTER NO-UNDO. MESSAGE "Reject message" VIEW-AS ALERT-BOX. errorCode = DYNAMIC-FUNCTION("getCharProperty" IN hMessage, "errorCode"). errorText = DYNAMIC-FUNCTION("getCharProperty" IN hMessage, "errorText"). exceptionCode = DYNAMIC-FUNCTION("getCharProperty" IN hMessage, "exception"). MESSAGE errorText VIEW-AS ALERT-BOX. DISPLAY errorCode exceptionCode. iNumParts = DYNAMIC-FUNCTION("getPartCount" IN hMessage). IF DYNAMIC-FUNCTION("isMessagePart" IN hMessage, 1) = TRUE THEN DO: contentType = DYNAMIC-FUNCTION("getMessagePartByIndex":U IN hMessage, INPUT iNumParts, OUTPUT hMessagePart). msgType = DYNAMIC-FUNCTION('getMessageType':U IN hMessagePart). DISPLAY iNumParts msgType contentType. END. RUN deleteMessage IN hMessage. END PROCEDURE. |