MQ

MQ

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  How to get the correct CorrID out of a message

    Posted Thu August 03, 2023 10:52 AM
    Edited by rniew Fri August 04, 2023 09:39 AM
    Hello.
     
    We have a Java ApplicationX running on Cloud in a container on Linux. It was previously running on WebSphere, was using some Webpshere MQ functions and there, all worked fine. Now it was rewritten to run in a container as a Java Application and using Spring Boot IBM JMS Library functions. 
     
    It uses JMS function to read from a REQqueueB. The message is originated by a WebSphere Consumer, it is put into a REQqueueA, processed by IIB, written to the REQqueueB, then read by the ApplicationX application and response is written to RESqueueC. Then processed by IIB, written to RESqueueD and read by the WebSphere Consumer.
     
    But at the end the WebSPhere application throws the error WSWS7166E: The JMSCorrelationID of the response message does not match the MessegeID of the intitial request message. But we see the correct correlID in the WebSphere trace which is not equal to the JMSCorrelationID. But it seams correlID it is not in the JMS MRFRH2, but most likely in the MQMD header. 
     
    The ApplicationX is doing request/response and uses the following to get and write the Correlation Id to the response message:
     
    String[] split = requestHeaders.getJMSMessageID().split("ID:");
    jmsResponseHeaders.setJMSCorrelationID(split[1]);
     
    We use the "getJMSMessageID().split("ID:")" because the JMSCorrelationID is "null" at that point. At least this is what we get out from the Spring Boot IBM JMS Library call. But WebSPhere throws an error for that JMSCorrelationID.  
     
    So we think that we somehow use the wrong function to get the correlID. It must be there in the message header. Possibly in the MQMD header. But no idea how to do it. We may need to use another IBM library. 
     
    Does someone is experienced in this area and can help?



    ------------------------------
    rniew
    ------------------------------



  • 2.  RE: How to get the correct CorrID out of a message

    Posted Fri August 04, 2023 08:19 AM
    Edited by Francois Brandelik Mon August 07, 2023 01:16 AM

    This is where you go wrong: 

    String[] split = requestHeaders.getJMSMessageID().split("ID:");
    jmsResponseHeaders.setJMSCorrelationID(split[1]);

    Accept that the correlation ID may be null and test for it. Accept that the correlation id can be all "00" (48 of them) and test for it.

    Your code should do

    if ( message.getJMSCorrelationID == null || message.getJMSCorrelationID () 
                 == "Id:000000000000000000000000000000000000000000000000") { //48* 0
        response.setJMSCorrelationID(message.getJMSMessageID());
      } else {
        response.setJMSCorrelationID(message.getJMSCorrelationID());
    }

    Hope it helps



    ------------------------------
    Francois Brandelik
    ------------------------------



  • 3.  RE: How to get the correct CorrID out of a message

    Posted Fri August 04, 2023 09:28 AM
    Edited by rniew Fri August 04, 2023 09:39 AM

    Thank you for your feedback.

    Which MQ/JMS libraries do you  include in your Java code? Asking because your code uses getMessageID and not getJMSMessageID. Appears to retrieve the ID from a different part of the message.

    Thx

    Ric



    ------------------------------
    rniew

    ------------------------------



  • 4.  RE: How to get the correct CorrID out of a message

    Posted Mon August 07, 2023 01:18 AM

    Corrected my previous post to use the JMS relevant method...



    ------------------------------
    Francois Brandelik
    ------------------------------



  • 5.  RE: How to get the correct CorrID out of a message

    Posted Mon August 07, 2023 03:38 AM

    Hello Francois.

    Thank you for your feedback. We will try it. However, based on your code, also getJMSMessageID would be done (because JMSCorrelID is null) and this is the ID which is considered as bad at the end of the chain.



    ------------------------------
    rniew
    ------------------------------



  • 6.  RE: How to get the correct CorrID out of a message

    Posted Wed August 09, 2023 05:11 AM
    Edited by Francois Brandelik Wed August 09, 2023 05:20 AM

    That's because you have 

    message    -> IIB / ACE ->  Application

    msgid        ->  A               ->   B

    correlid*1)      null    pass through    ->   null

    correlid *2         null  setting to F       ->    F

    correlid*3)      ->    null  setting to A     ->     A

    reply           -> Application  -> IIB/ACE -> Originator

    msgid         ->    C               ->      D       ->    D

    correlid *1)   ->  null set to B ->    B needs to be set to A     ->    B unable to match if ACE did not store and set to A.

    correlid *2)   ->  F set to F   ->      F set to F or null or D    ->  F or null or D unable to match

    correlid *3)    ->  A   set to A  ->     A set to A      ->     A  apllication matches.

     It is the responsibility of IIB/ACE to return the message to the originator with the correct correlation ID

    All depends on whether IIB / ACE parked the correlation / message id from the incoming message before forwarding that to the app.

    If IIB/ACE did not park the correlation ID they need to forward the message with a correlation id matching (the correlation id if not null (or initial), or the messageid if the correlation id is null or initial)



    ------------------------------
    Francois Brandelik
    ------------------------------