Topic
11 replies Latest Post - ‏2013-05-02T15:42:11Z by usw8de8
SystemAdmin
SystemAdmin
6772 Posts
ACCEPTED ANSWER

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
    1 Post
    ACCEPTED ANSWER

    Re: MQ Get based on a matching Correlation Id

    ‏2009-11-04T19:16:51Z  in response to SystemAdmin
    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
    ACCEPTED ANSWER

    Re: MQ Get based on a matching Correlation Id

    ‏2009-11-06T12:52:03Z  in response to SystemAdmin
    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
      ACCEPTED ANSWER

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

      ‏2011-12-24T01:06:38Z  in response to ashoon
      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
        ACCEPTED ANSWER

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

        ‏2011-12-26T20:42:55Z  in response to SystemAdmin
        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
          ACCEPTED ANSWER

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

          ‏2011-12-28T07:35:44Z  in response to Liv2luv
          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
            ACCEPTED ANSWER

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

            ‏2012-04-27T10:41:32Z  in response to SystemAdmin
            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
              ACCEPTED ANSWER

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

              ‏2012-05-02T10:22:40Z  in response to SystemAdmin
              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
              ACCEPTED ANSWER

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

              ‏2012-07-02T10:52:09Z  in response to SystemAdmin
              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
                ACCEPTED ANSWER

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

                ‏2012-07-02T11:53:27Z  in response to NajmaK
                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
                  ACCEPTED ANSWER

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

                  ‏2012-07-03T19:59:09Z  in response to NajmaK
                  Sinu Sekar and all

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

                  Regards,
                  Salla
    • usw8de8
      usw8de8
      2 Posts
      ACCEPTED ANSWER

      Re: MQ Get based on a matching Correlation Id

      ‏2013-05-02T15:42:11Z  in response to ashoon

      Hi,

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