spring-integration - Spring-Integration http:outbound-gateway with Hystrix
问题描述
有没有办法可以使用 Hystrix 命令包装 http:outbound 网关 REST API 调用。我看到了一些关于使用自定义请求处理程序建议的参考,但不确定我将如何去做。
解决方案
请参阅此处:使用 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
推荐阅读
- magento - XAMPP localhost 和 Magento 2 中的 mod_rewrite
- python - 以 2D 特征数组为输入的高斯过程 - scikit-learn
- python - CPLEX 与 Python API - 如何使模型制定更快?
- javascript - 是否有理由保留 express 变量
- docker - OCI 运行时创建失败:container_linux.go:348:
- java - 在 Servlet 中执行后将 JSP 请求重定向到自身
- c# - 询问 WebService 时 System.ServiceModel.WasHosting.dll 中的异常
- r - 为什么 Shiny 不在 tabItem 中呈现这些信息框
- swift - Swift - 锁定/点击按钮
- mongoose - 返回数据时的猫鼬格式日期