diff --git a/spring-cloud-alibaba-dependencies/pom.xml b/spring-cloud-alibaba-dependencies/pom.xml index c2177004d..c4867891a 100644 --- a/spring-cloud-alibaba-dependencies/pom.xml +++ b/spring-cloud-alibaba-dependencies/pom.xml @@ -19,7 +19,7 @@ 2022.0-SNAPSHOT - 1.8.1 + 1.8.3 1.3.0 1.4.3 0.8.0 diff --git a/spring-cloud-alibaba-examples/sentinel-example/sentinel-circuitbreaker-example/pom.xml b/spring-cloud-alibaba-examples/sentinel-example/sentinel-circuitbreaker-example/pom.xml index 20970a824..20abe2cc6 100644 --- a/spring-cloud-alibaba-examples/sentinel-example/sentinel-circuitbreaker-example/pom.xml +++ b/spring-cloud-alibaba-examples/sentinel-example/sentinel-circuitbreaker-example/pom.xml @@ -18,10 +18,6 @@ - - org.springframework.cloud - spring-cloud-starter-bootstrap - org.springframework.boot spring-boot-starter-web diff --git a/spring-cloud-alibaba-examples/sentinel-example/sentinel-circuitbreaker-example/readme-zh.md b/spring-cloud-alibaba-examples/sentinel-example/sentinel-circuitbreaker-example/readme-zh.md index 29efcf68b..6e621ae4e 100644 --- a/spring-cloud-alibaba-examples/sentinel-example/sentinel-circuitbreaker-example/readme-zh.md +++ b/spring-cloud-alibaba-examples/sentinel-example/sentinel-circuitbreaker-example/readme-zh.md @@ -56,8 +56,8 @@ feign: 再访问 http://localhost/test/default/true 断路器处于打开状态 验证指定 feign client 生效 -先访问 http://localhost/test/feign/true 2 次 -再访问 http://localhost/test/feign/false 断路器处于打开状态 +先访问 http://localhost/test/feign/false 2 次 +再访问 http://localhost/test/feign/true 断路器处于打开状态 验证 feign client 指定方法生效 先访问 http://localhost/test/feignMethod/false 2次 diff --git a/spring-cloud-alibaba-examples/sentinel-example/sentinel-circuitbreaker-example/readme.md b/spring-cloud-alibaba-examples/sentinel-example/sentinel-circuitbreaker-example/readme.md new file mode 100644 index 000000000..650f1962f --- /dev/null +++ b/spring-cloud-alibaba-examples/sentinel-example/sentinel-circuitbreaker-example/readme.md @@ -0,0 +1,68 @@ +# Sentinel Feign Circuit Breaker Example + +## Project description + +OpenFeign integrates Sentinel circuit breaker implementation + +## sample + +1. add dependency + +```xml + + + org.springframework.cloud + spring-cloud-starter-openfeign + +``` +2. add configuration to config center + +```yaml +feign: + circuitbreaker: + enabled: true # Enable feign circuit breaker support + sentinel: + default-rule: default # Default rule name + rules: + # Default rule, valid for all feign clients + default: + - grade: 2 # Downgrade based on number of exceptions + count: 1 + timeWindow: 15 # Time to half-open state after downgrade + statIntervalMs: 1000 + minRequestAmount: 1 + # Only valid for feign client user + user: + - grade: 2 + count: 1 + timeWindow: 15 + statIntervalMs: 1000 + minRequestAmount: 1 + # Only valid for the method feignMethod of the feign client user + # Parentheses are parameter types, separated by multiple commas, such as user#method(boolean,String,Map) + "[user#feignMethod(boolean)]": + - grade: 2 + count: 1 + timeWindow: 10 + statIntervalMs: 1000 + minRequestAmount: 1 +``` + +## Verify +Startup project + +Verify that the default feign client takes effect. +First visit http:localhost/test/default/false 2 times +and then visit http:localhost/test/default/true, the circuit breaker is open + +Verify that the specified feign client takes effect. +First visit http:localhost/test/feign/false 2 times +and then visit http:localhost/test/feign/true, the circuit breaker is open + +Verify that the specified method of feign client takes effect. +First visit http://localhost/test/feignMethod/false 2 times +and then visit http://localhost/test/feignMethod/true, the circuit breaker is open + +## Rules are dynamically refreshed +Modify the rules of the configuration center, and then access the above interface + diff --git a/spring-cloud-alibaba-examples/sentinel-example/sentinel-circuitbreaker-example/src/main/resources/bootstrap.yml b/spring-cloud-alibaba-examples/sentinel-example/sentinel-circuitbreaker-example/src/main/resources/application.yml similarity index 65% rename from spring-cloud-alibaba-examples/sentinel-example/sentinel-circuitbreaker-example/src/main/resources/bootstrap.yml rename to spring-cloud-alibaba-examples/sentinel-example/sentinel-circuitbreaker-example/src/main/resources/application.yml index 6d1b2332f..1a6426d24 100644 --- a/spring-cloud-alibaba-examples/sentinel-example/sentinel-circuitbreaker-example/src/main/resources/bootstrap.yml +++ b/spring-cloud-alibaba-examples/sentinel-example/sentinel-circuitbreaker-example/src/main/resources/application.yml @@ -7,5 +7,5 @@ spring: nacos: config: server-addr: 127.0.0.1:8848 - name: sentinel-circuitbreaker-rules.yml - file-extension: yml + config: + import: optional:nacos:sentinel-circuitbreaker-rules.yml