概述
Feign整合Sentinel
添加依赖
<!--sentinel依赖--> <dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> <version>2.2.8.RELEASE</version> </dependency>
配置文件
FeignClient
@Component//表示为ProductFeign提供降级逻辑 public class ProductFallbackFactory implements FallbackFactory<ProductFeign> { @Override public ProductFeign create(Throwable throwable) { return new ProductFeign() { @Override public Product getId(Integer pid) { System.out.println("getId降级了"); Product product = new Product(0,"降级了",new BigDecimal(0.0),0); return product; } @Override public String info() { return "info降级"; } }; } }
Sentinel控制台
访问
持久化
Push模式
结构图
启动
把原来的sentinel关掉,启动别人写好的带有持久化的jar包
再重新访问sentinel
在这里设置各种模式就会保存下来。
添加依赖
<dependency> <groupId>com.alibaba.csp</groupId> <artifactId>sentinel-datasource-nacos</artifactId> <version>1.8.1</version> </dependency>
修改配置文件
访问
product-flow-rules