需要安装sentinel
    https://github.com/alibaba/Sentinel/releases/download/1.6.3/sentinel-dashboard-1.6.3.jar
    pom.xml

    1. <dependency>
    2. <groupId>com.alibaba.cloud</groupId>
    3. <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
    4. </dependency>
    1. server:
    2. port: 8401
    3. spring:
    4. application:
    5. name: cloudalibaba-sentinel-service
    6. cloud:
    7. nacos:
    8. discovery:
    9. server-addr: localhost:8848 #Nacos服务注册中心地址
    10. sentinel:
    11. transport:
    12. dashboard: localhost:8080 #配置Sentinel dashboard地址
    13. port: 8719
    14. datasource:
    15. ds1:
    16. nacos:
    17. server-addr: localhost:8848
    18. dataId: ${spring.application.name}
    19. groupId: DEFAULT_GROUP
    20. data-type: json
    21. rule-type: flow
    22. management:
    23. endpoints:
    24. web:
    25. exposure:
    26. include: '*'


    image.png
    不需要在启动类上加注解

    用@sentinelResource(value=”fallback” fallback=”handlerFallback”)
    image.png

    blockHandler只负责控制台配置违规,也就是说如果设置了调用次数,那超出调用次数就执行blockHandler设置的方法
    image.png
    如果有业务违规和控制台配置的参数超过,那会执行blockHandler设置的方法
    image.png
    image.png

    feing 集成 sentinel:
    image.png
    image.png
    image.png