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

Set threshold and backout queue using XSLT for IBM MQ

  • 1.  Set threshold and backout queue using XSLT for IBM MQ

    Posted Fri December 22, 2023 11:35 AM

    Is there a way to set backout threshold and backout queue using XSLT? I'm not allowed to set this configuration in Datapower. So I'm trying to set this using XSLT. I have an XML file containing list of multiple target URLs and backout queues in it. I wan to set backout threshold value and backout count using XSL.

    Below is my xml config File (Route.xml):

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
       <environment>dev</environment>
    <ST_Q_DP>
          <target>dpmq://QMGR/RequestQueue=SA.Q</target>
          <backout-queue>dpmq://QMDP/?RequestQueue=BACKOUT.Q</backout-queue>
    </ST_Q_DP>
       <ST_Y_Q>
         <target>dpmq://QMGR/?RequestQueue=QA.IN</target>
          <backout-queue>dpmq://QMDP/?RequestQueue=BACKOUT.Q1</backout-queue>
       </ST_Y_Q>
       <ST_RY_Q>
          <target>dpmq://QMGR/?RequestQueue=QMDP.Q</target>
          <backout-queue>dpmq://QMDP/?RequestQueue=BACKOUT.Q2</backout-queue>
       </ST_RY_Q>
       <STM_Q>
          <target>dpmq://QMGR/?RequestQueue=QA.IN.FULL</target>
          <backout-queue>dpmq://QMDP/?RequestQueue=BACKOUT.Q3</backout-queue>
       </STM_Q>
       </configuration>

    In the XSLT I'm writing like this, could someone help me the correct way of writing this.

    <xsl:stylesheet
     version="1.1" 
     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:dpfunc="http://www.datapower.com/extensions/functions"
     extension-element-prefixes="dp dpconfig" 
     exclude-result-prefixes="dp dpconfig dpfunc">
     
     <xsl:include href="store:///utilities.xsl" />
     <xsl:import href="local:///Route.xml" />
     <xsl:template match="/">
     
     <xsl:choose>
        <xsl:when test="string-length($dpconfig:QManager) != 0">
    <!-- <xsl:when test="'var://service/backout-count'= 3 ">-->   
      <dp:url-open target="{$backout-queue}" response="ignore" >
    <xsl:copy-of select="dp:request-header('MQMD')" />
    </dp:url-open>
    <dp:set-variable name="'var://service/backout-count'" value="3" />
    </xsl:when>
    <xsl:otherwise>
           <xsl:copy-of select="$ErrorMessage" />
    </xsl:otherwise>
    </xsl:choose>
     
    <xsl:value-of disable-output-escaping="yes" select="dp:variable('var://service/formatted-error-message')" />
    <!--If Backout Queue is full, Reject-->
    <xsl:if test="starts-with($mqrc, '2') and string-length($mqrc)= 4">
    <!-- <xsl:if test="(starts-with($mqrc, '2') and (string-length(normalize-space($mqrc))= 4)) or ($ecode != '0x00000000')">  -->
    <dp:reject>MQ Error (RC: <xsl:value-of select="$mqrc"/>)</dp:reject>
    </xsl:if>
      <dp:set-variable name="'var://context/outbound/entriesMQMD'" value="$entriesMQMD" />  
    </xsl:template>
    </xsl:stylesheet>


    ------------------------------
    Gita Anasuri
    ------------------------------