You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Datapower中退避队列无负载及动态注入退避计数头问题咨询

问题解决方案

1. 修正代码语法错误

你现有代码的target属性存在引号书写错误,target="{$BackoutQ"}应改为target="{$BackoutQ}",否则会导致队列地址解析异常。

2. 动态注入退避计数

需要从原消息的MQMD中读取BackoutCount值,递增后写入新的MQMD节点:

  • 用dp:request-header('MQMD/BackoutCount')获取原退避计数,首次退避时默认值设为0
  • 对数值递增后,通过<mq:BackoutCount>节点覆盖原MQMD中的对应字段

3. 传递消息负载

在dp:url-open标签内添加原消息负载的拷贝,确保退避队列能收到完整的消息内容。

完整修正后的XSLT代码

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:dp="http://www.datapower.com/extensions"
    xmlns:mq="http://www.ibm.com/xmlns/prod/websphere/mq/7.0.0/mqmd"
    extension-element-prefixes="dp">

    <xsl:variable name="originalBackoutCount" select="dp:request-header('MQMD/BackoutCount')"/>
    <!-- 处理首次退避场景,默认退避计数为0 -->
    <xsl:variable name="newBackoutCount" select="number($originalBackoutCount) + 1"/>

    <xsl:template match="/">
        <dp:url-open target="{$BackoutQ}" 
            http-headers="$headers" 
            response="responsecode-ignore" 
            timeout="10" 
            data-type="xml">
            <!-- 拷贝原MQMD并更新退避计数 -->
            <mq:MQMD>
                <xsl:copy-of select="dp:request-header('MQMD/*') except dp:request-header('MQMD/BackoutCount')"/>
                <mq:BackoutCount><xsl:value-of select="$newBackoutCount"/></mq:BackoutCount>
            </mq:MQMD>
            <!-- 传递原消息负载 -->
            <xsl:copy-of select="/"/>
        </dp:url-open>
    </xsl:template>
</xsl:stylesheet>

关键说明

  • 命名空间引入:必须添加mq命名空间,否则MQMD节点无法被Datapower正确识别
  • 退避计数更新:通过except排除原MQMD中的旧退避计数字段,避免节点重复
  • 负载传递:<xsl:copy-of select="/"/>会将整个原消息内容拷贝到退避请求中,确保队列收到完整负载
  • 变量解析:修正后的target属性能正确解析$BackoutQ变量对应的退避队列地址

验证要点

  1. 确认$BackoutQ变量已配置为正确的MQ队列地址(格式示例:mq://queueManager/backoutQueue)
  2. 检查Datapower的MQ前端处理程序是否拥有退避队列的写入权限
  3. 可通过dp:trace()输出$newBackoutCount和负载内容,验证数据传递正确性

内容的提问来源于stack exchange,提问作者Daisy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 07:10:15