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

WSO2 ESB多消息存储下消息处理器重试与错误码处理问题

问题分析与解决方案

核心原因

你遇到的问题确实是因为消息处理器未收到处理成功的确认信号。当你使用<drop/>时,代理服务没有向消息处理器返回任何响应,消息处理器会认为此次投递失败,因此会继续重试该消息。

解决方案

不需要使用类中介器,通过调整代理服务的配置即可实现需求:在处理4xx错误时,将消息存入第二个存储后,向消息处理器返回一个200 OK状态码,让它认为消息已成功处理,从而从第一个存储中移除该消息并停止重试。

修正后的代理服务配置

<?xml version="1.0" encoding="UTF-8"?>
<proxy name="ProxyService" startOnLoad="true" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
    <target>
        <inSequence>
            <log level="full"/>
            <enrich>
                <source clone="true" type="body"/>
                <target property="data" type="property"/>
            </enrich>
            <call>
                <endpoint>
                    <http method="post" statistics="enable" trace="enable" uri-template="http://localhost:3001/transfers"></http>
                </endpoint>
            </call>
            <filter regex="200" source="$axis2:HTTP_SC">
                <then>
                    <log level="custom">
                        <property name="text" value="Endpoint Call Success"/>
                    </log>
                </then>
                <else>
                    <filter regex="4[0-9]{2}" source="get-property('axis2', 'HTTP_SC')">
                        <then>
                            <log level="custom">
                                <property name="text" value="Client Error Occurred while Sending Message"/>
                            </log>
                            <store messageStore="second-store"/>
                            <!-- 设置200状态码,通知消息处理器停止重试并移除消息 -->
                            <property name="HTTP_SC" value="200" scope="axis2"/>
                        </then>
                        <else>
                            <log level="custom">
                                <property name="text" value="Other Error Occurred while Sending Message"/>
                            </log>
                        </else>
                    </filter>
                </else>
            </filter>
            <respond/>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </target>
</proxy>

关键调整说明

  1. 移除<drop/>:不再终止序列,而是通过<respond/>返回响应。
  2. 设置HTTP_SC为200:在4xx错误处理块中,将Axis2属性HTTP_SC设为200,这样代理服务会向消息处理器返回200 OK状态。
  3. 利用non.retry.status.codes:你的消息处理器已配置non.retry.status.codes=200,当它收到200响应时,会将消息标记为处理成功,从第一个存储中移除并停止重试。

其他错误的重试逻辑

对于非4xx错误(如5xx),我们保留原始的HTTP状态码,消息处理器会根据max.delivery.attempts=5的配置,最多重试5次。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.24 19:42:08