springboot整合Sentinel实现熔断降级

1.sentinel的功能:

        1.可以监控服务状态

        2.可以和openfeign整合,进行被动降级(服务端异常)

        3.sentinel可以进行主动设置,进行降级和熔断

2.在pom中添加依赖配置

<!--        加上sentinel-->
        <dependency>
            <groupId>com.alibaba.csp</groupId>
            <artifactId>sentinel-datasource-nacos</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
        </dependency>

3.编写sentinel配置文件

spring:
  cloud:
    sentinel:
      transport:
        #        配置sentinel的服务地址及端口
        dashboard: localhost:8080
        #        配置应用与sentinel控制台交互的端口,应用本地会起一个该端口的占用httpserver
        clientIp: localhost
        port: 8719

4.启动sentinel服务端的jar包:sentinel-dashboard-1.8.2.jar

5.此时就可以在sentinel的服务端进行(注意每次服务启动需要重启sentinel)

 


版权声明:本文为qq_1757537040原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。