Topic
  • 5 replies
  • Latest Post - ‏2015-11-06T06:00:23Z by A09
SystemAdmin
SystemAdmin
6772 Posts

Pinned topic How to Give a New Msg Id when sending Msg to Queue using url-open

‏2010-10-15T01:18:59Z |
Hi,
I have a MPG which pick a message from request queue and sends it to a webservice.
On the response from webservice in the MPG response rule i want to send a copy of the request content saved in a context variable to a queue using url-open if the response matches a criteria and by setting a msg id which is retrieved from the request MQMD properties.

1) I am able to send the msg to the desired queue but the msgid is not getting populated and is being over ridden with the MQ generated default msg id.
2) i have tried with providing PMO options in url-open but unable to set this msgid.
3) What headers i need to set for the provided msg id to be assigned instead of the default msg id given by the Queue.
<xsl:stylesheet version="1.0" extension-element-prefixes="dp" exclude-result-prefixes="dp dpconfig" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:date="http://exslt.org/dates-and-times" xmlns:dp="http://www.datapower.com/extensions" xmlns:dpconfig="http://www.datapower.com/param/config">
<xsl:output method="xml"/>
<xsl:template match="/">

<!-- Msg id retained from request -->
<xsl:variable name="MsgId" select="dp:variable('var://context/Request/MessageID')"/>
<xsl:variable name="QueueManager" select="dp:variable('var://context/Request/QueueManager')"/>

<!--If the Response from Webservice contains a string 'TryAgain'then Msg will be Sent to Copy Queue -->
<xsl:choose>
<xsl:if test="contains(/*/*/*/*, 'TryAgain')">

<xsl:variable name="tempMqmd">
<MQMD>
<Format>MQSTR</Format>
<MsgId><xsl:value-of select="$MsgId"/></MsgId>
<CorrelId>111111111111111111111111111111111111111111111111</CorrelId>
</MQMD>
</xsl:variable>

<xsl:variable name="MQMD-Str">
<dp:serialize select="$tempMqmd" />
</xsl:variable>

<xsl:variable name="mqmdSubstr">
<xsl:value-of select="substring-after($MQMD-Str, '?>')" />
</xsl:variable>
<xsl:variable name="mqUrl" select="concat('dpmq://',$QueueManager,'/?RequestQueue=REQUEST.COPY;PMO=1028')" />
<dp:url-open target="{$mqUrl}" response="ignore">
<xsl:copy-of select="dp:variable('var://context/Request/RequestMsgContent')"/>
<dp:set-variable name="'var://local/_extension/header/MQMD'" value="substring-after($MQMD-Str, '?>')" />
</dp:url-open>

</xsl:if>

</xsl:template>
</xsl:stylesheet>
Updated on 2010-10-15T06:22:04Z at 2010-10-15T06:22:04Z by SystemAdmin
  • Liv2luv
    Liv2luv
    573 Posts

    Re: How to Give a New Msg Id when sending Msg to Queue using url-open

    ‏2010-10-15T03:23:51Z  
    Not sure if you have used the XSLT posted here in Datapower.

    Following code will help you get what you need.

    <xsl:variable name="entries" select="dp:request-header('MQMD')"/>
                    <xsl:variable name="mqHeader" select="dp:parse($entries)"/>
                    <xsl:variable name="msgID" select="$mqHeader//MsgId"/>
                    <xsl:variable name="newMQMDStr">
                            <MQMD>
                                    <MsgId>
                                            <xsl:value-of select="$MsgId"/>
                                    </MsgId>
                            </MQMD>
                    </xsl:variable>
                    <xsl:variable name="mqmdStr">
                            <dp:serialize select="$newMQMDStr" omit-xml-decl="yes"/>
                    </xsl:variable>
                    <dp:set-response-header name="'MQMD'" value="$mqmdStr"/>
    


    Thanks.
    Updated on 2014-03-25T03:38:19Z at 2014-03-25T03:38:19Z by iron-man
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: How to Give a New Msg Id when sending Msg to Queue using url-open

    ‏2010-10-15T05:33:14Z  
    rbk99,

    this is wht u have to do..

    <xsl:variable name="MQMD">
    <MQMD>
    <Format>
    <xsl:value-of select="'MQSTR '"/>
    </Format>
    <MsgId>
    <xsl:value-of select="$MsgId"/>
    </MsgId>
    </MQMD>
    </xsl:variable>

    <xsl:variable name="serializedMQMD">
    <dp:serialize select="$MQMD"/>
    </xsl:variable>

    <!-- NOTE: below the extra header element added after serializing the mqmd header -->
    <xsl:variable name="newSerializedMQMD">
    <header name="MQMD">
    <xsl:value-of select="$serializedMQMD" />
    </header>
    </xsl:variable>

    <!-- NOTE: below, in url-open mqmd can be set using http-headers attr -->

    <dp:url-open target="dpmq://MQM/URI?RequestQueue=QUEUENAME;PMO=8192" http-headers="$newSerializedMQMD" >
    <xsl:copy-of select="."/>
    </dp:url-open>

    Jitu
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: How to Give a New Msg Id when sending Msg to Queue using url-open

    ‏2010-10-15T06:04:19Z  
    • Liv2luv
    • ‏2010-10-15T03:23:51Z
    Not sure if you have used the XSLT posted here in Datapower.

    Following code will help you get what you need.

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><xsl:variable name="entries" select="dp:request-header('MQMD')"/> <xsl:variable name="mqHeader" select="dp:parse($entries)"/> <xsl:variable name="msgID" select="$mqHeader//MsgId"/> <xsl:variable name="newMQMDStr"> <MQMD> <MsgId> <xsl:value-of select="$MsgId"/> </MsgId> </MQMD> </xsl:variable> <xsl:variable name="mqmdStr"> <dp:serialize select="$newMQMDStr" omit-xml-decl="yes"/> </xsl:variable> <dp:set-response-header name="'MQMD'" value="$mqmdStr"/> </pre>

    Thanks.
    I have created the MQMD structure as mentioned by you and trying to send the MQMD header using url-open as below , even then the MsgId is not being set.

    <xsl:variable name="headerValues">
    <header name="'MQMD'"><xsl:value-of select="substring-after($mqmdStr, '?>')" /></header>
    </xsl:variable>

    <xsl:variable name="mqUrl" select="concat('dpmq://',$QueueManager,'/?RequestQueue=REQUEST.COPY;PMO=1028')" />
    <dp:url-open target="{$mqUrl}" response="ignore" http-headers="$headerValues">
    <xsl:copy-of select="dp:variable('var://context/Request/RequestMsgContent')"/>
    </dp:url-open>
    Thanks
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: How to Give a New Msg Id when sending Msg to Queue using url-open

    ‏2010-10-15T06:22:04Z  
    rbk99,

    this is wht u have to do..

    <xsl:variable name="MQMD">
    <MQMD>
    <Format>
    <xsl:value-of select="'MQSTR '"/>
    </Format>
    <MsgId>
    <xsl:value-of select="$MsgId"/>
    </MsgId>
    </MQMD>
    </xsl:variable>

    <xsl:variable name="serializedMQMD">
    <dp:serialize select="$MQMD"/>
    </xsl:variable>

    <!-- NOTE: below the extra header element added after serializing the mqmd header -->
    <xsl:variable name="newSerializedMQMD">
    <header name="MQMD">
    <xsl:value-of select="$serializedMQMD" />
    </header>
    </xsl:variable>

    <!-- NOTE: below, in url-open mqmd can be set using http-headers attr -->

    <dp:url-open target="dpmq://MQM/URI?RequestQueue=QUEUENAME;PMO=8192" http-headers="$newSerializedMQMD" >
    <xsl:copy-of select="."/>
    </dp:url-open>

    Jitu
    Thanks Jitu it worked.
    Really appreciate your help.

    Thanks Liv2luv's
  • A09
    A09
    1 Post

    Re: How to Give a New Msg Id when sending Msg to Queue using url-open

    ‏2015-11-06T06:00:23Z  
    Thanks Jitu it worked.
    Really appreciate your help.

    Thanks Liv2luv's

    Hi,

     

    I have used the same code to update application identity data but its not working. Even the msgID is not getting updated... Please help/