[progress Communities] [progress Openedge Abl] Forum Post: Re: Connect To Websphere Mq...

Status
Not open for further replies.
F

Fuelfire

Guest
Hello, everybody! I will try to show the the problem on example. Here, the program for message receiving: /* *************************** Main Block *************************** */ DEFINE VAR QueueManager AS CHAR NO-UNDO. DEFINE VAR QueueName AS CHAR NO-UNDO. DEFINE VAR CMessage AS CHAR INITIAL "" NO-UNDO. DEFINE VARIABLE cErr AS CHAR FORMAT "X(255)" NO-UNDO. DEFINE VARIABLE ptpsession AS HANDLE. DEFINE VARIABLE consumerH AS HANDLE. DEFINE VARIABLE stillWaiting AS LOGICAL NO-UNDO INITIAL TRUE. ASSIGN QueueManager = "RemoteCF" QueueName = "TEST.Q". /* Creates a session object. */ RUN jms/jmssession.p PERSISTENT SET ptpsession ("-H localhost -S 3620 -AppService AD.sonicMQ1 -DirectConnect") NO-ERROR. IF ERROR-STATUS:ERROR THEN DO: ASSIGN cErr = ERROR-STATUS:GET-MESSAGE(1). RETURN "1". END. RUN setBrokerURL IN ptpsession (INPUT QueueManager) NO-ERROR. IF ERROR-STATUS:ERROR THEN DO: ASSIGN cErr = ERROR-STATUS:GET-MESSAGE(1). RETURN "1". END. /* Set user credentials. */ RUN setUser IN ptpsession (INPUT "swiftmq"). RUN setPassword IN ptpsession (INPUT "swiftmq"). /* Connect to the broker. */ RUN beginSession IN ptpsession NO-ERROR. IF ERROR-STATUS:ERROR THEN DO: ASSIGN cErr = ERROR-STATUS:GET-MESSAGE(1). RETURN "1". END. /* Subscribe to the Sample.Q1 queue. Messages are handled by the "messageHandler" internal procedure. */ RUN createMessageConsumer IN ptpsession (THIS-PROCEDURE, /* This proc will handle it */ "messageHandler", /* name of internal procedure */ OUTPUT consumerH). /* Do not create a new message for each received message */ RUN setReuseMessage IN consumerH. RUN receiveFromQueue IN ptpsession (QueueName, /* name of queue */ ?, /* No message selector */ consumerH) NO-ERROR. /* Handles incoming messages*/ IF ERROR-STATUS:ERROR THEN DO: ASSIGN cErr = ERROR-STATUS:GET-MESSAGE(1). RETURN "1". END. /* Start receiving messages */ RUN startReceiveMessages IN ptpsession. RUN waitForMessages IN ptpsession ("inWait", THIS-PROCEDURE, 5) NO-ERROR. IF ERROR-STATUS:ERROR THEN DO: ASSIGN cErr = ERROR-STATUS:GET-MESSAGE(1). MESSAGE cErr VIEW-AS ALERT-BOX. RETURN "1". END. RUN deleteSession IN ptpsession. MESSAGE cMessage VIEW-AS ALERT-BOX. RETURN "0". PROCEDURE messageHandler: DEFINE INPUT PARAMETER messageH AS HANDLE. DEFINE INPUT PARAMETER msgConsumerH AS HANDLE. DEFINE OUTPUT PARAMETER replyH AS HANDLE. /* Creates a reply message. The reply is published automatically when control returns to the ABL-JMS implementation. */ ASSIGN CMessage = DYNAMIC-FUNCTION('getText':U IN messageH). RUN deleteMessage IN messageH. ASSIGN stillWaiting = FALSE. END. FUNCTION inWait RETURNS LOGICAL: RETURN stillWaiting. END. When I run this program, I get the last message in the queue several times. If I delete string RUN deleteSession IN ptpsession. I get the last message once (and it's correct). But there is a line Client was disconnected without calling deleteSession()! (9294) in the soniqMQ1.server.log. That is, if I do not delete the session, the program works correctly. This is normal?

Continue reading...
 
Status
Not open for further replies.
Top