【问题标题】:Fallback Method for Circuit Breaker in Spring Integration弹簧集成中断路器的后备方法
【发布时间】:2019-05-14 21:56:11
【问题描述】:

我正在尝试在使用 spring 集成调用肥皂服务时实现断路器。断路器按预期工作。问题是我需要在电路打开时实现回退机制。请提出可能的实施方式。

弹簧集成.xml

<int:chain input-channel="BLR" output-channel="location.reply.out" >
        <ws:header-enricher>
            <ws:soap-action value="${bangalore-service.quote.soap.action.value}"/>
        </ws:header-enricher>

        <ws:outbound-gateway uri="#{locationDetailsProperties.getBlrServiceEndPoint()}">
             <ws:request-handler-advice-chain>
               <bean class="org.springframework.integration.handler.advice.RequestHandlerCircuitBreakerAdvice">
                    <property name="threshold" value="3" />
                    <property name="halfOpenAfter" value="60000" /> 
               </bean>
            </ws:request-handler-advice-chain>
        </ws:outbound-gateway>    
    </int:chain>

【问题讨论】:

    标签: spring-integration


    【解决方案1】:

    您需要显示您的上游流程。

    您应该将错误通道添加到启动流程的任何地方,并为其订阅错误处理流程; ErrorMessage 有效负载是带有 failedMessagecause 属性的消息异常,请扫描原因树以查找 CircuitBreakerOpenException

    【讨论】:

    • 您可以在RequestHandlerCircuitBreakerAdvice 之前使用ExpressionEvaluatingRequestHandlerAdvice 并在failureChannel 中处理CircuitBreakerOpenException,重新抛出所有其他异常。
    • @ArtemBilan 感谢您的回复。我已经实现了 ExpressionEvaluatingRequestHandlerAdvice 并且它按预期工作。
    • @Gary Russell,感谢您的回复。我会努力落实您的建议。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-19
    • 1970-01-01
    相关资源
    最近更新 更多