Topic
  • 13 replies
  • Latest Post - ‏2014-10-29T16:04:46Z by Sudarshan Bandaru
SystemAdmin
SystemAdmin
6772 Posts

Pinned topic MQ Get based on a matching Correlation Id

‏2009-08-05T18:28:39Z |
Hello All,

I am working on a use case where the PUT and Get and separate web service calls.
During the Put, I am responding back with the Message ID that will be used for correlation during a GET Call.
I use a stylesheet to parse the Message ID out of the response headers to return it to the Caller.

Now during get, I need to specify the Correlation ID for match and here is what I am doing.
I am setting the DP variable var://context/INPUT/_extension/header/X-MQMD-Get
to
<MQMD><CorrelId>414d512044502e514d475220202020204a7752f620027903</CorrelId></MQMD>
and my MQ URL looks like this
dpmq://QMObject/?ReplyQueue=ResponseQ;MatchOptions=2

MatchOptions=2 because the value of GMO option for matching correlation ID is 2.

I am not getting a message which matches the correlation id, but just any message from the Q.

Am I missing something here?
I also tried setting the MQMD header shown above to the header using set-request-header and set-response-header, but that didnt work either.

I see a lot of documentation on controlling the ReplyQ but none on how to set GET Options and a comprehensive list of options with their Values that can be specified. I have went through the DataPower book on Integrating with MQ and it talks about the variables I used above to control the Get Options. Please let me know if I am missing any step here.

I did see an example in the DataPower book to loop through messages and look for a message using Browse option, but i really dont want to do that in DataPower and the Q's could have thousands of mesages and it could become a really expensive operation.

Regards,
Sinu
Updated on 2012-07-03T19:59:09Z at 2012-07-03T19:59:09Z by SystemAdmin
  • Charlie Price
    Charlie Price
    3 Posts

    Re: MQ Get based on a matching Correlation Id

    ‏2009-11-04T19:16:51Z  
    Have you made any progress on this? I have the same problem, have tried many different
    options without success. I'm opening a problem this afternoon on the DataPower queue.

    Charlie
  • ashoon
    ashoon
    66 Posts

    Re: MQ Get based on a matching Correlation Id

    ‏2009-11-06T12:52:03Z  
    here's an xsl that maybe helpful.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:dp="http://www.datapower.com/extensions"
    xmlns:dpconfig="http://www.datapower.com/param/config" xmlns:date="http://exslt.org/dates-and-times"
    extension-element-prefixes="dp dpconfig date"
    version="1.0">

    <xsl:template match="/">

    <xsl:variable name="msgId" select="/mqMsgId"/>

    <xsl:variable name="mqmd">
    <MQMD>
    <MsgId><xsl:value-of select="$msgId"/></MsgId>
    </MQMD>
    </xsl:variable>
    <xsl:variable name="headers">
    <header name="X-MQMD-GET">
    <dp:serialize select="$mqmd" omit-xml-decl="yes"/>
    </header>
    </xsl:variable>

    <dp:url-open http-headers="$headers" target="dpmq://devQueueManager/?ReplyQueue=MQSTORETEST" response="xml"/>

    </xsl:template>
    </xsl:stylesheet>
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: MQ Get based on a matching Correlation Id and message id

    ‏2011-12-24T01:06:38Z  
    • ashoon
    • ‏2009-11-06T12:52:03Z
    here's an xsl that maybe helpful.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:dp="http://www.datapower.com/extensions"
    xmlns:dpconfig="http://www.datapower.com/param/config" xmlns:date="http://exslt.org/dates-and-times"
    extension-element-prefixes="dp dpconfig date"
    version="1.0">

    <xsl:template match="/">

    <xsl:variable name="msgId" select="/mqMsgId"/>

    <xsl:variable name="mqmd">
    <MQMD>
    <MsgId><xsl:value-of select="$msgId"/></MsgId>
    </MQMD>
    </xsl:variable>
    <xsl:variable name="headers">
    <header name="X-MQMD-GET">
    <dp:serialize select="$mqmd" omit-xml-decl="yes"/>
    </header>
    </xsl:variable>

    <dp:url-open http-headers="$headers" target="dpmq://devQueueManager/?ReplyQueue=MQSTORETEST" response="xml"/>

    </xsl:template>
    </xsl:stylesheet>
    Hi ,

    I have a similar requirement .I need to write a stylesheet where i have to get the correlationId from the request .
    Based on this correlation id I need to look into Test.queue and get the msg and have to look for queue manager name and msg id.
    This is something like the way datapower retrieves the msg .
    so how datapower retrieves the correlationId and send the response back to the client.

    Any help would be appreciated.

    Thanks,
    Karthikeya
  • Liv2luv
    Liv2luv
    573 Posts

    Re: MQ Get based on a matching Correlation Id and message id

    ‏2011-12-26T20:42:55Z  
    Hi ,

    I have a similar requirement .I need to write a stylesheet where i have to get the correlationId from the request .
    Based on this correlation id I need to look into Test.queue and get the msg and have to look for queue manager name and msg id.
    This is something like the way datapower retrieves the msg .
    so how datapower retrieves the correlationId and send the response back to the client.

    Any help would be appreciated.

    Thanks,
    Karthikeya
    Look at this technote for some more information: http://www-01.ibm.com/support/docview.wss?uid=swg21504752

    It again refers back to the same thread though ;)
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: MQ Get based on a matching Correlation Id and message id

    ‏2011-12-28T07:35:44Z  
    • Liv2luv
    • ‏2011-12-26T20:42:55Z
    Look at this technote for some more information: http://www-01.ibm.com/support/docview.wss?uid=swg21504752

    It again refers back to the same thread though ;)
    Hi ,

    Could you please let me know if the following will work as i am little new to stylesheets .

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:dp="http://www.datapower.com/extensions"
    xmlns:dpconfig="http://www.datapower.com/param/config" xmlns:date="http://exslt.org/dates-and-times"
    extension-element-prefixes="dp dpconfig date"
    version="1.0">

    <xsl:template match="/">

    <xsl:variable name="msgId" select="/mqMsgId"/>

    <!-- get MQMD-->
    <xsl:variable name="entries" select="dp:parse(dp:request-header('MQMD'))"/>

    <!-- recup du CorrelId -->
    <xsl:variable name="CorrelId" select="$entries//CorrelId"/>

    <xsl:variable name="mqmd">
    <MQMD>
    <MsgId><xsl:value-of select="$msgId"/></MsgId>
    </MQMD>
    </xsl:variable>

    <xsl:variable name="headers">
    <header name="X-MQMD-GET">
    <dp:serialize select="$mqmd" omit-xml-decl="yes"/>
    </header>
    </xsl:variable>

    <dp:url-open http-headers="$headers" target="dpmq://devQueueManager/?ReplyQueue=MQSTORETEST" response="xml"/>

    </xsl:template>
    </xsl:stylesheet>
    Thanks,
    Karthikeyan
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: MQ Get based on a matching Correlation Id and message id

    ‏2012-04-27T10:41:32Z  
    Hi ,

    Could you please let me know if the following will work as i am little new to stylesheets .

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:dp="http://www.datapower.com/extensions"
    xmlns:dpconfig="http://www.datapower.com/param/config" xmlns:date="http://exslt.org/dates-and-times"
    extension-element-prefixes="dp dpconfig date"
    version="1.0">

    <xsl:template match="/">

    <xsl:variable name="msgId" select="/mqMsgId"/>

    <!-- get MQMD-->
    <xsl:variable name="entries" select="dp:parse(dp:request-header('MQMD'))"/>

    <!-- recup du CorrelId -->
    <xsl:variable name="CorrelId" select="$entries//CorrelId"/>

    <xsl:variable name="mqmd">
    <MQMD>
    <MsgId><xsl:value-of select="$msgId"/></MsgId>
    </MQMD>
    </xsl:variable>

    <xsl:variable name="headers">
    <header name="X-MQMD-GET">
    <dp:serialize select="$mqmd" omit-xml-decl="yes"/>
    </header>
    </xsl:variable>

    <dp:url-open http-headers="$headers" target="dpmq://devQueueManager/?ReplyQueue=MQSTORETEST" response="xml"/>

    </xsl:template>
    </xsl:stylesheet>
    Thanks,
    Karthikeyan
    Hi All,

    i am also looking for your help in same scenario.I want to use MQMD header action of datapower or XSL which can take carrelationid from req and bring back the response with same MSg ID.

    Any help is appreciated..pls.

    Thanks,
    J
  • ytshen
    ytshen
    12 Posts

    Re: MQ Get based on a matching Correlation Id and message id

    ‏2012-05-02T10:22:40Z  
    Hi All,

    i am also looking for your help in same scenario.I want to use MQMD header action of datapower or XSL which can take carrelationid from req and bring back the response with same MSg ID.

    Any help is appreciated..pls.

    Thanks,
    J
    Use <xsl:value-of select="dp:variable('var://service/message-identifier')"/> to get request correl id.

    Use the following xslt to set the correl id for response.

    <xsl:variable name="mess" select="dp:variable('var://context/junk/identifier')"/>

    <xsl:template match="/">
    <dp:set-response-header name="'MQMD'" value="concat('&lt;MQMD>&lt;CodedCharSetId>1208&lt;/CodedCharSetId>&lt;CorrelId>', $mess, '&lt;/CorrelId>&lt;/MQMD>')"/>
    <xsl:copy-of select="."/>
    </xsl:template>
  • NajmaK
    NajmaK
    4 Posts

    Re: MQ Get based on a matching Correlation Id and message id

    ‏2012-07-02T10:52:09Z  
    Hi All,

    i am also looking for your help in same scenario.I want to use MQMD header action of datapower or XSL which can take carrelationid from req and bring back the response with same MSg ID.

    Any help is appreciated..pls.

    Thanks,
    J
    Hi,

    I am also facing the same problem.

    Could you please let me know if this got solved.

    <xsl:variable name="mqmd" select="concat('&lt;MQMD>&lt;MsgId>',$msgId,'&lt;/MsgId>&lt;/MQMD>')"/>
    <xsl:variable name="headers">
    <header name="X-MQMD-GET">
    <dp:serialize select="$mqmd" omit-xml-decl="yes"/>
    </header>
    </xsl:variable>
    <dp:url-open target="{$RespURL}" http-headers="$headers" response="xml"/>

    I tried even setting the below variables.

    <dp:set-variable name="'var://context/INPUT/_extension/header/X-MQMD-Get'" value="concat('&lt;MQMD>&lt;MsgId>', $msgId, '&lt;/MsgId>&lt;/MQMD>')"/>
    <dp:set-variable name="'var://local/_extension/header/X-MQMD-Get'" value="concat('&lt;MQMD>&lt;MsgId>', $msgId, '&lt;/MsgId>&lt;/MQMD>')"/>
    It retrieves the first message from the queue. It does not look for the message Id.

    Could you please let me know what is wrong here.

    Thank You,

    Najma Banu K
  • NajmaK
    NajmaK
    4 Posts

    Re: MQ Get based on a matching Correlation Id and message id

    ‏2012-07-02T11:53:27Z  
    • NajmaK
    • ‏2012-07-02T10:52:09Z
    Hi,

    I am also facing the same problem.

    Could you please let me know if this got solved.

    <xsl:variable name="mqmd" select="concat('&lt;MQMD>&lt;MsgId>',$msgId,'&lt;/MsgId>&lt;/MQMD>')"/>
    <xsl:variable name="headers">
    <header name="X-MQMD-GET">
    <dp:serialize select="$mqmd" omit-xml-decl="yes"/>
    </header>
    </xsl:variable>
    <dp:url-open target="{$RespURL}" http-headers="$headers" response="xml"/>

    I tried even setting the below variables.

    <dp:set-variable name="'var://context/INPUT/_extension/header/X-MQMD-Get'" value="concat('&lt;MQMD>&lt;MsgId>', $msgId, '&lt;/MsgId>&lt;/MQMD>')"/>
    <dp:set-variable name="'var://local/_extension/header/X-MQMD-Get'" value="concat('&lt;MQMD>&lt;MsgId>', $msgId, '&lt;/MsgId>&lt;/MQMD>')"/>
    It retrieves the first message from the queue. It does not look for the message Id.

    Could you please let me know what is wrong here.

    Thank You,

    Najma Banu K
    Hi,

    I followed this link and it got solved.

    http://ibm.sitecelerate.com/developerworks/forums/thread.jspa?threadID=377905&tstart=0#14641250
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: MQ Get based on a matching Correlation Id and message id

    ‏2012-07-03T19:59:09Z  
    • NajmaK
    • ‏2012-07-02T11:53:27Z
    Hi,

    I followed this link and it got solved.

    http://ibm.sitecelerate.com/developerworks/forums/thread.jspa?threadID=377905&tstart=0#14641250
    Sinu Sekar and all

    This is a great work. Thanks for sharing such a good use case!!!

    Regards,
    Salla
  • usw8de8
    usw8de8
    5 Posts

    Re: MQ Get based on a matching Correlation Id

    ‏2013-05-02T15:42:11Z  
    • ashoon
    • ‏2009-11-06T12:52:03Z
    here's an xsl that maybe helpful.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:dp="http://www.datapower.com/extensions"
    xmlns:dpconfig="http://www.datapower.com/param/config" xmlns:date="http://exslt.org/dates-and-times"
    extension-element-prefixes="dp dpconfig date"
    version="1.0">

    <xsl:template match="/">

    <xsl:variable name="msgId" select="/mqMsgId"/>

    <xsl:variable name="mqmd">
    <MQMD>
    <MsgId><xsl:value-of select="$msgId"/></MsgId>
    </MQMD>
    </xsl:variable>
    <xsl:variable name="headers">
    <header name="X-MQMD-GET">
    <dp:serialize select="$mqmd" omit-xml-decl="yes"/>
    </header>
    </xsl:variable>

    <dp:url-open http-headers="$headers" target="dpmq://devQueueManager/?ReplyQueue=MQSTORETEST" response="xml"/>

    </xsl:template>
    </xsl:stylesheet>

    Hi,

    Can you please let me know in which rule I need to set the xslt? (Request rule or Response rule, pls confirm.)

     

  • vinceisvince
    vinceisvince
    2 Posts

    Re: MQ Get based on a matching Correlation Id and message id

    ‏2014-09-25T16:20:49Z  
    • NajmaK
    • ‏2012-07-02T11:53:27Z
    Hi,

    I followed this link and it got solved.

    http://ibm.sitecelerate.com/developerworks/forums/thread.jspa?threadID=377905&tstart=0#14641250

    This link does not work.  I am having the same issue where it is pulling the first message off the queue and not searching by MsgId.  I've tried numerous things to get this to work but nothing is working.  The key is I am using url-open to do this.

     

    I am able to set headers when sending in a request but this is a async process so when I try to read off the queue it's not functioning correctly by MSGID.

  • Sudarshan Bandaru
    Sudarshan Bandaru
    50 Posts

    Re: MQ Get based on a matching Correlation Id and message id

    ‏2014-10-29T16:04:46Z  
    • NajmaK
    • ‏2012-07-02T11:53:27Z
    Hi,

    I followed this link and it got solved.

    http://ibm.sitecelerate.com/developerworks/forums/thread.jspa?threadID=377905&tstart=0#14641250

    Hi Nazma,

    The link is not opening, could you please let me know what is the procedure you have follwed to solve the issue.