restful限流

1.引入依赖

  1. <dependency>
  2. <groupId>com.xy</groupId>
  3. <artifactId>xy-core-framework-flow-sentinel</artifactId>
  4. <version>${xy-core-framework-flow-sentinel-version}</version>
  5. </dependency>

2.添加配置

  1. ########################### 负载均衡 ##############################################
  2. spring.cloud.loadbalancer.retry.enabled=true
  3. spring.cloud.sentinel.enabled=true
  4. spring.cloud.sentinel.transport.dashboard=${local.ip}:8858
  5. spring.cloud.sentinel.transport.port=8719
  6. #应用与Sentinel控制台的心跳间隔时间
  7. spring.cloud.sentinel.transport.heartbeat-interval-ms=1000
  8. #Sentinel自动化配置是否生效
  9. spring.cloud.sentinel.filter.enabled=true
  10. spring.cloud.sentinel.metric.charset=UTF-8
  11. #取消Sentinel控制台懒加载
  12. spring.cloud.sentinel.eager=true
  13. #Sentinel 日志文件所在的目录
  14. spring.cloud.sentinel.log.dir=./logs/${spring.application.name}/sentinel
  15. #默认开启
  16. spring.cloud.sentinel.xy.enable=true
  17. #默认开启
  18. spring.cloud.sentinel.xy.mvc-interceptor-enable=true
  19. #默认关闭
  20. spring.cloud.sentinel.xy.total-interceptor-enable=false

dubbo限流

1.引入依赖

  1. <dependency>
  2. <groupId>com.xy</groupId>
  3. <artifactId>xy-core-framework-flow-sentinel-dubbo-adapter</artifactId>
  4. <version>${xy-core-framework-flow-sentinel-dubbo-version}</version>
  5. </dependency>