【问题标题】:Mule ESB simple http request with rollback exception strategy带有回滚异常策略的 Mule ESB 简单 http 请求
【发布时间】:2015-05-02 22:40:24
【问题描述】:

我正在尝试执行以下操作:

  1. 调用不存在的api
  2. 尝试重新传递原始请求 5 次
  3. 发送结束时打印一条消息

我有以下流程:

<http:request-config name="HTTP_Request_Configuration" host="localhost" port="80" doc:name="HTTP Request Configuration"/>
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="exceptionTestFlow">
    <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
    <flow-ref name="exceptionTestSubFlow" doc:name="Flow Reference"/>
</flow>
<flow name="exceptionTestSubFlow">
    <http:request config-ref="HTTP_Request_Configuration" path="/hello/" method="GET" doc:name="HTTP"/>
    <rollback-exception-strategy doc:name="Rollback Exception Strategy" maxRedeliveryAttempts="5">
        <logger message="redelivering..." level="INFO" doc:name="Logger"/>
        <on-redelivery-attempts-exceeded>
            <logger message="redelivery exhausted" level="INFO" doc:name="Logger"/>
        </on-redelivery-attempts-exceeded>
    </rollback-exception-strategy>
</flow>

但我得到以下输出:

错误 2015-03-02 14:15:34,820 [[exceptiontest].HTTP_Listener_Configuration.worker.01] org.mule.exception.RollbackMessagingExceptionStrategy:


消息:响应代码 404 映射为失败。消息负载类型:BufferInputStream

代码:MULE_ERROR--2

异常堆栈是: 1. 响应代码 404 映射为失败。消息负载类型:BufferInputStream (org.mule.module.http.internal.request.ResponseValidatorException)

org.mule.module.http.internal.request.SuccessStatusCodeValidator:37 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/module/http/internal/request/ResponseValidatorException.html)

根异常堆栈跟踪: org.mule.module.http.internal.request.ResponseValidatorException:响应代码 404 映射为失败。消息有效负载的类型:BufferInputStream 在 org.mule.module.http.internal.request.SuccessStatusCodeValidator.validate(SuccessStatusCodeValidator.java:37) 在 org.mule.module.http.internal.request.DefaultHttpRequester.innerProcess(DefaultHttpRequester.java:202) 在 org.mule.module.http.internal.request.DefaultHttpRequester.process(DefaultHttpRequester.java:166) + 3 个以上(设置调试级别日志记录或 '-Dmule.verbose.exceptions=true' 为所有内容)


INFO 2015-03-02 14:15:34,820 [[exceptiontest].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor:重新发送... 错误 2015-03-02 14:15:34,822 [[exceptiontest].HTTP_Listener_Configuration.worker.01] org.mule.exception.DefaultMessagingExceptionStrategy:


消息:响应代码 404 映射为失败。消息负载类型:BufferInputStream

代码:MULE_ERROR--2

异常堆栈是: 1. 响应代码 404 映射为失败。消息负载类型:BufferInputStream (org.mule.module.http.internal.request.ResponseValidatorException)

org.mule.module.http.internal.request.SuccessStatusCodeValidator:37 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/module/http/internal/request/ResponseValidatorException.html)

根异常堆栈跟踪: org.mule.module.http.internal.request.ResponseValidatorException:响应代码 404 映射为失败。消息有效负载的类型:BufferInputStream 在 org.mule.module.http.internal.request.SuccessStatusCodeValidator.validate(SuccessStatusCodeValidator.java:37) 在 org.mule.module.http.internal.request.DefaultHttpRequester.innerProcess(DefaultHttpRequester.java:202) 在 org.mule.module.http.internal.request.DefaultHttpRequester.process(DefaultHttpRequester.java:166) + 3 个以上(设置调试级别日志记录或 '-Dmule.verbose.exceptions=true' 为所有内容)


我预计它会尝试重新投递 5 次,但它似乎不起作用。我做错了什么吗?非常感谢。

ps 我已经尝试将子流包装在事务块中,但这也不起作用

【问题讨论】:

    标签: http mule esb rollback


    【解决方案1】:

    我会改为使用Until Successful Scope,因为我认为 HTTP 不支持重新传递(请参阅文档以了解 Rollback Exception Strategy)。

    【讨论】:

      【解决方案2】:

      由于 HTTP 调用是一个无状态对象,定义回滚似乎不是一个好的选择。 在 until-successful 范围内定义您所需的失败条件,并且相应的重试次数似乎是实现您的要求的好选择。

      供参考 UntilSuccessful component to poll http endpoint till condition is met

      【讨论】:

        猜你喜欢
        • 2015-07-03
        • 1970-01-01
        • 1970-01-01
        • 2023-03-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多