maven 配置
Spring Boot 2.2.5.RELEASE Spring Cloud Hoxton.SR3 Spring Alibaba 2.2.1.RELEASE
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-datasource-nacos</artifactId>
</dependency>
配置流控规则后,始终不生效。原因是缺少配置:
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-parameter-flow-control</artifactId>
</dependency>
关于Sentinel-Dashboard
微服务连接的Sentinel后,我们在Sentinel-Dashboard里面能看见gateway-server,但是看不见里面具体的链路。
原理解析:
当我们的Sentinel-Dashboard跑在公网上的时候,我们用内外服务去连接Sentinel,由于我们的微服务只有内网地址,没有公网地址,导致Sentinel-Dashboard去请求Sentinel-client数据时候,拉取失败,看不到链路信息。