update doc and update component version (#3206)

pull/3208/head
YuLuo 2 years ago committed by GitHub
parent 9c86f76eae
commit d852dd89cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,8 +19,8 @@
<properties>
<revision>2021.0.4.0-SNAPSHOT</revision>
<sentinel.version>1.8.5</sentinel.version>
<seata.version>1.5.2</seata.version>
<sentinel.version>1.8.6</sentinel.version>
<seata.version>1.6.1</seata.version>
<nacos.client.version>2.2.0</nacos.client.version>
<spring.context.support.version>1.0.11</spring.context.support.version>
@ -227,7 +227,6 @@
<artifactId>spring-context-support</artifactId>
<version>${spring.context.support.version}</version>
</dependency>
<!-- Testing Dependencies -->
</dependencies>

@ -4,18 +4,19 @@ Spring Cloud Alibaba BOM 包含了它所使用的所有依赖的版本。
如果您是 Maven Central 用户,请将我们的 BOM 添加到您的 pom.xml 中的 <dependencyManagement> 部分。 这将允许您省略任何Maven依赖项的版本而是将版本控制委派给BOM。
```xml
[source,xml]
----
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2021.0.1.0</version>
<version>2021.0.5.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
```
----
在下面的章节中,假设您使用的是 Spring Cloud Alibaba bom相关 starter 依赖将不包含版本号。

@ -8,7 +8,9 @@
=== 升级步骤
升级版本 (注意版本对应关系)
```xml
[source,xml]
----
<dependencyManagement>
<dependency>
<groupId>org.springframework.boot</groupId>
@ -32,7 +34,7 @@
<scope>import</scope>
</dependency>
</dependencyManagement>
```
----
*注意事项:* `spring-cloud-starter-alibaba-nacos-config` 模块移除了 `spring-cloud-starter-bootstrap` 依赖,如果你想以旧版的方式使用,你需要手动加上该依赖,现在推荐使用 `spring.config.import` 方式引入配置

@ -57,7 +57,7 @@ Seata是一个分布式事务框架, 用于保证在微服务架构下每个服
=== Seata Dashboard
- Seata 1.5.1支持Seata控制台本地访问控制台地址:`http://127.0.0.1:7091`。
- Seata从1.5.0版本之后支持Seata控制台本地访问控制台地址:`http://127.0.0.1:7091`。
- 通过Seata控制台可以观察到正在执行的事务信息和全局锁信息并且在事务完成时删除相关信息。

@ -15,17 +15,18 @@ https://github.com/alibaba/Sentinel[Sentinel] 具有以下特征:
如果要在您的项目中引入 Sentinel使用 group ID 为 `com.alibaba.cloud` 和 artifact ID 为 `spring-cloud-starter-alibaba-sentinel` 的 starter。
```xml
[source,yaml]
[source,xml]
----
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
```
----
下面这个例子就是一个最简单的使用 Sentinel 的例子:
```java
[source,java]
----
@SpringBootApplication
public class Application {
@ -45,7 +46,7 @@ public class TestController {
}
}
```
----
@SentinelResource 注解用来标识资源是否被限流、降级。上述例子上该注解的属性 'hello' 表示资源名。
@ -53,7 +54,8 @@ public class TestController {
以上例子都是在 WebServlet 环境下使用的Sentinel 目前已经支持 WebFlux需要配合 `spring-boot-starter-webflux` 依赖触发 sentinel-starter 中 WebFlux 相关的自动化配置。
```java
[source,java]
----
@SpringBootApplication
public class Application {
@ -74,11 +76,11 @@ public class TestController {
}
}
```
----
===== Sentinel 控制台
Sentinel 控制台提供一个轻量级的控制台,它提供机器发现、单机资源实时监控、集群资源汇总,以及规则管理的功能。您只需要对应用进行简单的配置,就可以使用这些功能。
Sentinel官方社区提供一个轻量级的控制台,它提供机器发现、单机资源实时监控、集群资源汇总,以及规则管理的功能。您只需要对应用进行简单的配置,就可以使用这些功能。
*注意*: 集群资源汇总仅支持 500 台以下的应用集群,有大概 1 - 2 秒的延时。
@ -101,9 +103,10 @@ image::https://github.com/alibaba/Sentinel/wiki/image/dashboard.png[]
Sentinel 控制台是一个标准的 SpringBoot 应用,以 SpringBoot 的方式运行 jar 包即可。
```shell
[source,shell]
----
java -Dserver.port=8080 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard.jar
```
----
如若8080端口冲突可使用 `-Dserver.port=新端口` 进行设置。
@ -129,16 +132,19 @@ Sentinel 适配了 https://github.com/OpenFeign/feign[OpenFeign] 组件。如果
* 配置文件打开 sentinel 对 feign 的支持:`feign.sentinel.enabled=true`
* 加入 `openfeign starter` 依赖使 `sentinel starter` 中的自动化配置类生效:
```xml
[source,xml]
----
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
```
----
这是一个 `FeignClient` 的简单使用示例:
```java
[source,java]
----
@FeignClient(name = "service-provider", fallback = EchoServiceFallback.class, configuration = FeignConfiguration.class)
public interface EchoService {
@GetMapping(value = "/echo/{str}")
@ -158,7 +164,7 @@ class EchoServiceFallback implements EchoService {
return "echo fallback";
}
}
```
----
NOTE: Feign 对应的接口中的资源名策略定义httpmethod:protocol://requesturl。`@FeignClient` 注解中的所有属性Sentinel 都做了兼容。
@ -168,13 +174,14 @@ NOTE: Feign 对应的接口中的资源名策略定义httpmethod:protocol://r
Spring Cloud Alibaba Sentinel 支持对 `RestTemplate` 的服务调用使用 Sentinel 进行保护,在构造 `RestTemplate` bean的时候需要加上 `@SentinelRestTemplate` 注解。
```java
[source,java]
----
@Bean
@SentinelRestTemplate(blockHandler = "handleException", blockHandlerClass = ExceptionUtil.class)
public RestTemplate restTemplate() {
return new RestTemplate();
}
```
----
`@SentinelRestTemplate` 注解的属性支持限流(`blockHandler`, `blockHandlerClass`)和降级(`fallback`, `fallbackClass`)的处理。
@ -184,13 +191,14 @@ public RestTemplate restTemplate() {
比如上述 `@SentinelRestTemplate` 注解中 `ExceptionUtil` 的 `handleException` 属性对应的方法声明如下:
```java
[source,java]
----
public class ExceptionUtil {
public static ClientHttpResponse handleException(HttpRequest request, byte[] body, ClientHttpRequestExecution execution, BlockException exception) {
...
}
}
```
----
NOTE: 应用启动的时候会检查 `@SentinelRestTemplate` 注解对应的限流或降级方法是否存在,如不存在会抛出异常
@ -260,7 +268,8 @@ https://github.com/alibaba/Sentinel/wiki/%E7%BD%91%E5%85%B3%E9%99%90%E6%B5%81[
若想跟 Sentinel Starter 配合使用,需要加上 `spring-cloud-alibaba-sentinel-gateway` 依赖,同时需要添加 `spring-cloud-starter-gateway` 依赖来让 `spring-cloud-alibaba-sentinel-gateway` 模块里的 Spring Cloud Gateway 自动化配置类生效:
```xml
[source,xml]
----
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
@ -275,7 +284,7 @@ https://github.com/alibaba/Sentinel/wiki/%E7%BD%91%E5%85%B3%E9%99%90%E6%B5%81[
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
```
----
=== Sentinel 对外暴露的 Endpoint

@ -2,18 +2,19 @@
If youre a Maven Central user, add our BOM to your pom.xml <dependencyManagement> section. This will allow you to omit versions for any of the Maven dependencies and instead delegate versioning to the BOM.
```xml
[source,xml]
----
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2021.0.1.0</version>
<version>2021.0.5.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
```
----
In the following sections, it will be assumed you are using the Spring Cloud Alibaba BOM and the dependency snippets will not contain versions.

@ -7,7 +7,9 @@ Starting from 2021.0.1.0, the SCA version will correspond to the Spring Cloud ve
=== Upgrade Steps
Upgrade version (note the version correspondence)
```xml
[source,xml]
----
<dependencyManagement>
<dependency>
<groupId>org.springframework.boot</groupId>
@ -31,7 +33,7 @@ Upgrade version (note the version correspondence)
<scope>import</scope>
</dependency>
</dependencyManagement>
```
----
*Note:* The `spring-cloud-starter-alibaba-nacos-config` module removes the `spring-cloud-starter-bootstrap` dependency. If you want to use with the bootstrap way, you need to manually add this dependency, now recommended to import configuration using `spring.config.import`.
@ -43,7 +45,8 @@ After completing the above steps, you can smoothly switch to the `Spring Cloud A
Suppose there is a configuration file (`bootstrap.yml`) here, how should it be configured to upgrade to a new version?
```yaml
[source,yaml]
----
# bootstrap.yml
spring:
cloud:
@ -58,11 +61,12 @@ spring:
- dataId: test02.yml
group: group_02
refresh: false
```
----
The two configurations are equivalent.
```yaml
[source,yaml]
----
# application.yml
spring:
cloud:
@ -76,7 +80,7 @@ spring:
- optional:nacos:test01.yml?group=group_01 # Override default grouplistening group_01:test01.yml
- optional:nacos:test02.yml?group=group_02&refreshEnabled=false # Do not enable dynamic refresh
- nacos:test03.yml # When the nacos configuration is pulled abnormally, it will fail quickly, which will cause the Spring container to fail to start.
```
----
Note:
@ -109,15 +113,19 @@ Add new configuration item `spring.cloud.nacos.discovery.failure-tolerance-enabl
When Sentinel is implemented as a Spring Cloud circuit breaker, support for adding circuit breaker configuration for each FeignClient.
Add dependency.
```xml
[source,xml]
----
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-circuitbreaker-sentinel</artifactId>
</dependency>
```
----
And here are two FeignClient
```java
[source,java]
----
@FeignClient(value = "user", fallback = UserFallback.class)
public interface UserClient {
@GetMapping("/{success}")
@ -131,7 +139,7 @@ public interface OrderClient {
@GetMapping("/{success}")
String error(@PathVariable Boolean success);
}
```
----
Now there are these requirements:
@ -140,7 +148,9 @@ Now there are these requirements:
3. I want to configure a circuit breaker for the specified method (error) of order FeignClient.
Add the following configuration.
```yaml
[source,yaml]
----
feign:
circuitbreaker:
enabled: true
@ -171,7 +181,7 @@ feign:
timeWindow: 1
statIntervalMs: 1000
minRequestAmount: 5
```
----
This feature also supports dynamic refresh from the configuration center. You can put the above configuration into the configuration center (nacos, consul), and the modified rules will take effect immediately. If you do not need this feature, you can set `feign.sentinel.enable-refresh-rules=false` to disable it.

@ -58,7 +58,7 @@ The project provides relevant https://github.com/alibaba/spring-cloud-alibaba/tr
=== Seata Dashboard
- Seata 1.5.1 supports Seata console local access console address: `http://127.0.0.1:7091`。
- Seata supports the Seata console since version 1.5.0, and the local access console address: 'http://127.0.0.1:7091'.
- Through the Seata console, you can observe the executing transaction information and global lock information, and delete the relevant information when the transaction is completed.

@ -16,16 +16,18 @@ https://github.com/alibaba/Sentinel[Sentinel] has the following features:
If you want to use Sentinel in your project, please use the starter with the group ID as `com.alibaba.cloud` and the artifact ID as `spring-cloud-starter-alibaba-sentinel`.
```xml
[source,xml]
----
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
```
----
The following is a simple example of how to use Sentinel:
```java
[source,java]
----
@SpringBootApplication
public class Application {
@ -45,7 +47,7 @@ public class TestController {
}
}
```
----
The @SentinelResource annotation is used to identify if a resource is rate limited or degraded. In the above sample, the 'hello' attribute of the annotation refers to the resource name.
@ -53,7 +55,8 @@ The @SentinelResource annotation is used to identify if a resource is rate limit
The above examples are all used in the WebServlet environment. Sentinel currently supports WebFlux and needs to cooperate with the `spring-boot-starter-webflux` dependency to trigger the WebFlux-related automation configuration in sentinel starter.
```java
[source,java]
----
@SpringBootApplication
public class Application {
@ -74,12 +77,11 @@ public class TestController {
}
}
```
----
===== Sentinel Dashboard
Sentinel dashboard is a lightweight console that provides functions such as machine discovery, single-server resource monitoring, overview of cluster resource data, as well as rule management. To use these features, you only need to complete a few steps.
The Sentinel community provides a lightweight console that provides machine discovery, real-time monitoring of stand-alone resources, cluster resource aggregation, and rule management. All you need is a simple configuration of your app to use these features.
*Note*: The statistics overview for clusters only supports clusters with less than 500 nodes, and has a latency of about 1 to 2 seconds.
.Sentinel Dashboard
@ -101,9 +103,10 @@ You can also get the latest source code to build your own Sentinel dashboard
Sentinel dashboard is a standard SpringBoot application, and you can run the JAR file in the Spring Boot mode.
```shell
[source,shell]
----
java -Dserver.port=8080 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard.jar
```
----
If there is conflict with the 8080 port, you can use `-Dserver.port=new port` to define a new port.
@ -130,16 +133,19 @@ Sentinel is compatible with the https://github.com/OpenFeign/feign[OpenFeign] co
* Enable the Sentinel support for feign in the properties file. `feign.sentinel.enabled=true`
* Add the `openfeign starter` dependency to trigger and enable `sentinel starter`:
```xml
[source,xml]
----
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
```
----
This is a simple usage of `FeignClient`:
```java
[source,java]
----
@FeignClient(name = "service-provider", fallback = EchoServiceFallback.class, configuration = FeignConfiguration.class)
public interface EchoService {
@GetMapping(value = "/echo/{str}")
@ -159,7 +165,7 @@ class EchoServiceFallback implements EchoService {
return "echo fallback";
}
}
```
----
NOTE: The resource name policy in the corresponding interface of Feign ishttpmethod:protocol://requesturl. All the attributes in the `@FeignClient` annotation is supported by Sentinel.
@ -169,13 +175,14 @@ The corresponding resource name of the `echo` method in the `EchoService` interf
Spring Cloud Alibaba Sentinel supports the protection of `RestTemplate` service calls using Sentinel. To do this, you need to add the `@SentinelRestTemplate` annotation when constructing the `RestTemplate` bean.
```java
[source,java]
----
@Bean
@SentinelRestTemplate(blockHandler = "handleException", blockHandlerClass = ExceptionUtil.class)
public RestTemplate restTemplate() {
return new RestTemplate();
}
```
----
The attribute of the `@SentinelRestTemplate` annotation support flow control(`blockHandler`, `blockHandlerClass`) and circuit breaking(`fallback`, `fallbackClass`).
@ -187,13 +194,14 @@ The parameter and return value of method in `@SentinelRestTemplate` is same as `
The method signature of `handleException` in `ExceptionUtil` above should be like this:
```java
[source,java]
----
public class ExceptionUtil {
public static ClientHttpResponse handleException(HttpRequest request, byte[] body, ClientHttpRequestExecution execution, BlockException exception) {
...
}
}
```
----
NOTE: When the application starts, it will check if the `@SentinelRestTemplate` annotation corresponding to the flow control or circuit breaking method exists, if it does not exist, it will throw an exception.
@ -261,7 +269,8 @@ Refer https://github.com/alibaba/Sentinel/wiki/API-Gateway-Flow-Control[API Gate
If you want to use Sentinel Starter with Spring Cloud Gateway, you need to add the `spring-cloud-alibaba-sentinel-gateway` dependency and add the `spring-cloud-starter-gateway` dependency to let Spring Cloud Gateway AutoConfiguration class in the module takes effect:
```xml
[source,xml]
----
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
@ -276,7 +285,7 @@ If you want to use Sentinel Starter with Spring Cloud Gateway, you need to add t
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
```
----
include::circuitbreaker-sentinel.adoc[]

Loading…
Cancel
Save