首页 > 解决方案 > Spring-Integration http:outbound-gateway with Hystrix

问题描述

有没有办法可以使用 Hystrix 命令包装 http:outbound 网关 REST API 调用。我看到了一些关于使用自定义请求处理程序建议的参考,但不确定我将如何去做。

标签: spring-integrationhystrixspring-integration-http

解决方案


请参阅此处:使用 hystrix 命令包装 spring 集成出站网关调用。我无法结束您的问题,duplicate因为没有人投票支持我的答案。但仍然:必须为您的用例应用相同的解决方案:

@ServiceActivator(inputChannel = "serviceChannel")
@HystrixCommand(fallbackMethod = "serviceFallback")
public String myService(String payload) {
    // Some external service call
}

public String serviceFallback(String payload) {
    // some fallback logic
}

另请参阅我的发送箱中的示例:https ://github.com/artembilan/sendbox/tree/master/spring-integration-with-hystrix


推荐阅读