@ -1,54 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>spring-cloud-alibaba-docs</artifactId>
|
||||
<name>Spring Cloud Alibaba Documentation</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<docs.main>spring-cloud-alibaba</docs.main>
|
||||
<main.basedir>${basedir}/..</main.basedir>
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>docs</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.asciidoctor</groupId>
|
||||
<artifactId>asciidoctor-maven-plugin</artifactId>
|
||||
<inherited>false</inherited>
|
||||
<configuration>
|
||||
<sourceDirectory>${basedir}/src/main/asciidoc-zh</sourceDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.agilejava.docbkx</groupId>
|
||||
<artifactId>docbkx-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<inherited>false</inherited>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
Before Width: | Height: | Size: 144 KiB |
Before Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 2.0 MiB |
Before Width: | Height: | Size: 2.0 MiB |
Before Width: | Height: | Size: 1.9 MiB |
Before Width: | Height: | Size: 1.9 MiB |
Before Width: | Height: | Size: 1.9 MiB |
Before Width: | Height: | Size: 2.4 MiB |
Before Width: | Height: | Size: 156 KiB |
@ -1,38 +0,0 @@
|
||||
[[spring-cloud-alibaba-reference]]
|
||||
= Spring Cloud Alibaba 参考文档
|
||||
Jim Fang, Jing Xiao, Mercy Ma, Xiaolong Zuo, Bingting Peng, Yuxin Wang
|
||||
:doctype: book
|
||||
:toc:
|
||||
:toclevels: 4
|
||||
:source-highlighter: prettify
|
||||
:numbered:
|
||||
|
||||
include::introduction.adoc[]
|
||||
|
||||
include::dependency-management.adoc[]
|
||||
|
||||
include::nacos-discovery.adoc[]
|
||||
|
||||
include::nacos-config.adoc[]
|
||||
|
||||
include::sentinel.adoc[]
|
||||
|
||||
include::rocketmq-new.adoc[]
|
||||
|
||||
include::ans.adoc[]
|
||||
|
||||
include::acm.adoc[]
|
||||
|
||||
include::oss.adoc[]
|
||||
|
||||
include::schedulerx.adoc[]
|
||||
|
||||
include::sms.adoc[]
|
||||
|
||||
include::sidecar.adoc[]
|
||||
|
||||
include::appactive.adoc[]
|
||||
|
||||
include::governance.adoc[]
|
||||
|
||||
|
@ -1,178 +0,0 @@
|
||||
== Spring Cloud Alibaba Cloud ACM
|
||||
|
||||
Spring Cloud AliCloud ACM is an implementation of the commercial product Application Configuration Management(ACM) in the client side of Spring Cloud, and is free of charge.
|
||||
|
||||
Use Spring Cloud AliCloud ACM to quickly access ACM configuration management capabilities based on Spring Cloud's programming model.
|
||||
|
||||
NOTE: Currently EDAS already supports direct deployment of the Nacos Config app.
|
||||
|
||||
=== How to Introduce Spring Cloud Alibaba Cloud ACM
|
||||
|
||||
If you want to use ACM in your project, please use the starter with the group ID as `com.alibaba.cloud` and the artifact ID as `spring-cloud-starter-alicloud-acm`.
|
||||
|
||||
[source,xml]
|
||||
----
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alicloud-acm</artifactId>
|
||||
</dependency>
|
||||
----
|
||||
|
||||
=== Use ACM to Manage Configurations
|
||||
|
||||
When Spring Cloud Alibaba Cloud ACM Starter is introduced into the client, the application will automatically get configuration information from the configuration management server when it starts, and inject the configuration into Spring Environment.
|
||||
|
||||
The following is a simple illustration.
|
||||
|
||||
[source,java]
|
||||
----
|
||||
@SpringBootApplication
|
||||
public class ProviderApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ConfigurableApplicationContext applicationContext = SpringApplication.run(ProviderApplication.class, args);
|
||||
String userName = applicationContext.getEnvironment().getProperty("user.name");
|
||||
String userAge = applicationContext.getEnvironment().getProperty("user.age");
|
||||
System.err.println("user name :" +userName+"; age: "+userAge);
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
As we need to obtain configuration information from the configuration server, we will need to configure the address of the server. We also need to add the following information in bootstrap.properties.
|
||||
|
||||
[source,properties]
|
||||
----
|
||||
# Required. The application name will be used as part of the keyword to get the configuration key from the server.
|
||||
spring.application.name=acm-config
|
||||
server.port=18081
|
||||
# The following is the IP and port number of the configuration server.
|
||||
spring.cloud.alicloud.acm.server-list=127.0.0.1
|
||||
spring.cloud.alicloud.acm.server-port=8080
|
||||
----
|
||||
|
||||
NOTE: By now the configuration center is not started yet, so you will get an error message if your application is started. Therefore, start the configuration center before you start your application.
|
||||
|
||||
|
||||
==== Start Configuration Center
|
||||
|
||||
ACM uses two types of configuration centers. One is lightweight configuration center, the other is ACM which is used on Alibaba Cloud. Generally, you can use the lightweight version for application development and local testing, and use ACM for canary deployment or production.
|
||||
|
||||
===== Use Lightweight Configuration Center
|
||||
|
||||
Refer to the https://help.aliyun.com/document_detail/44163.html[Configure Lightweight Configuration Center] for details about how to download and install lightweight configuration center.
|
||||
|
||||
NOTE: You only need to perform step 1(Download lightweight configuration center) and step 2(Start lightweight configuration center).
|
||||
|
||||
|
||||
===== Use ACM on the Alibaba Cloud
|
||||
|
||||
Using ACM on the cloud saves you from the tedious work of server maintenance while at the same time provides a better stability. There is no difference at the code level between using ACM on cloud and lightweight configuration center, but there are some differences in configurations.
|
||||
|
||||
The following is a simple sample of using ACM. You can view configuration details on https://acm.console.aliyun.com[ACM Console]
|
||||
|
||||
[source,properties]
|
||||
----
|
||||
# The application name will be used as part of the keyword to obtain configuration key from the server, and is mandatory.
|
||||
spring.application.name=acm-config
|
||||
# Configure your own port number
|
||||
server.port=18081
|
||||
# The following is the IP and port number of the configuration center.
|
||||
spring.cloud.alicloud.acm.server-mode=EDAS
|
||||
spring.cloud.alicloud.access-key=Your Alibaba Cloud AK
|
||||
spring.cloud.alicloud.secret-key=Your Alibaba Cloud SK
|
||||
spring.cloud.alicloud.acm.endpoint=acm.aliyun.com
|
||||
spring.cloud.alicloud.acm.namespace=Your ACM namespace(You can find the namespace on the ACM console)
|
||||
----
|
||||
|
||||
NOTE: EDAS provides application hosting service and will fill in all configurations about ACM automatically for the hosted applications.
|
||||
|
||||
==== Add Configuration in the Configuration Center
|
||||
|
||||
1. After you start the lightweight configuration center, add the following configuration on the console.
|
||||
|
||||
[source,subs="normal"]
|
||||
----
|
||||
Group: DEFAULT_GROOUP
|
||||
|
||||
DataId: acm-config.properties
|
||||
|
||||
Content: user.name=james
|
||||
user.age=18
|
||||
----
|
||||
|
||||
NOTE: The format of dataId is `{prefix}. {file-extension}`. “prefix” is obtained from spring.application.name by default, and the value of “file-extension” is "properties” by default.
|
||||
|
||||
==== Start Application Verification
|
||||
|
||||
Start the following example and you can see that the value printed on the console is the value we configured in the lightweight configuration center.
|
||||
|
||||
[source,subs="normal"]
|
||||
----
|
||||
user name :james; age: 18
|
||||
----
|
||||
|
||||
=== Modify Configuration File Extension
|
||||
|
||||
The default file extension of dataId in spring-cloud-starter-alicloud-acm is properties. In addition to properties, yaml is also supported.
|
||||
You can set the file extension using spring.cloud.alicloud.acm.file-extension. Just set it to `yaml` or `yml`for yaml format.
|
||||
|
||||
NOTE: After you change the file extension, you need to make corresponding format changes in the DataID and content of the configuration center.
|
||||
|
||||
=== Dynamic Configuration Refresh
|
||||
|
||||
spring-cloud-starter-alicloud-acm supports dynamic configuration updates. RefreshEvent in Spring is published when you update configuration in the configuration center.
|
||||
All classes with @RefreshScope and @ConfigurationProperties annotations will be refreshed automatically.
|
||||
|
||||
NOTE: You can disable automatic refresh by this setting: spring.cloud.alicloud.acm.refresh.enabled=false
|
||||
|
||||
=== Configure Profile Granularity
|
||||
|
||||
When configuration is loaded by spring-cloud-starter-alicloud-acm, configuration with DataId {spring.application.name}. {file-extension} will be loaded first. If there is content in spring.profiles.active, the content of spring.profile, and configuration with the dataid format of{spring.application.name}-{profile}. {file-extension} will also be loaded in turn, and the latter has higher priority.
|
||||
|
||||
spring.profiles.active is the configuration metadata, and should also be configured in bootstrap.properties or bootstrap.yaml. For example, you can add the following content in bootstrap.properties.
|
||||
|
||||
[sources,properties]
|
||||
----
|
||||
spring.profiles.active={profile-name}
|
||||
----
|
||||
|
||||
Note: You can also configure the granularity through JVM parameters such as -Dspring.profiles.active=develop or --spring.profiles.active=develop, which have higher priority. Just follow the specifications of Spring Boot.
|
||||
|
||||
|
||||
=== Support Custom ACM Timeout
|
||||
|
||||
the default timeout of ACM client get config from sever is 3000 ms . If you need to define a timeout, set configuration `spring.cloud.alicloud.acm.timeout`,the unit is millisecond.
|
||||
|
||||
|
||||
=== Support Custom Group Configurations
|
||||
|
||||
DEFAULT_GROUP is used by default when no `{spring.cloud.alicloud.acm.group}` configuration is defined. If you need to define your own group, you can use the following method:
|
||||
|
||||
[source,properties]
|
||||
----
|
||||
spring.cloud.alicloud.acm.group=DEVELOP_GROUP
|
||||
----
|
||||
|
||||
NOTE: This configuration must be placed in the bootstrap.properties file, and the value of Group must be the same with the value of `spring.cloud.alicloud.acm.group`.
|
||||
|
||||
==== Support Shared Configurations
|
||||
|
||||
ACM provides a solution to share the same configuration across multiple applications. You can do this by adding the `spring.application.group` configuration in Bootstrap.
|
||||
|
||||
[source,properties]
|
||||
----
|
||||
spring.application.group=company.department.team
|
||||
----
|
||||
|
||||
Then, you application will retrieve configurations from the following DataId in turn before it retrieves its own configuration: company:application.properties, company.department:application.properties, company.department.team:application.properties.
|
||||
After that, it also retrieves configuration from {spring.application.group}: {spring.application.name}. {file-extension}
|
||||
The later in order, the higer the priority, and the unique configuration of the application itself has the highest priority.
|
||||
|
||||
|
||||
NOTE: The default suffix of DataId is properties, and you can change it using spring.cloud.alicloud.acm.file-extension. `{spring.application.group}: {spring.application.name}. {file-extension}` .
|
||||
|
||||
NOTE: If you configured `spring.profiles.active` , then the DataId format of `{spring.application.group}: {spring.application.name}-{spring.profiles.active}. {file-extension}` is also supported, and has higher priority than `{spring.application.group}: {spring.application.name}. {file-extension}`
|
||||
|
||||
=== Actuator Endpoint
|
||||
|
||||
the Actuator endpoint of ACM is `/acm`, `config` represents the ACM metadata configuration information, `runtime.sources` corresponds to the configuration information obtained from the ACM server and the last refresh time, `runtime.refreshHistory` corresponds to the dynamic refresh history.
|
@ -1,73 +0,0 @@
|
||||
=== Circuit Breaker: Spring Cloud Circuit Breaker With Sentinel & Configuring Sentinel Circuit Breakers
|
||||
|
||||
==== Default Configuration
|
||||
|
||||
To provide a default configuration for all of your circuit breakers create a `Customizer` bean that is passed a
|
||||
`SentinelCircuitBreakerFactory` or `ReactiveSentinelCircuitBreakerFactory`.
|
||||
The `configureDefault` method can be used to provide a default configuration.
|
||||
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
@Bean
|
||||
public Customizer<SentinelCircuitBreakerFactory> defaultCustomizer() {
|
||||
return factory -> factory.configureDefault(id -> new SentinelConfigBuilder(id)
|
||||
.build());
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
You can choose to provide default circuit breaking rules via `SentinelConfigBuilder#rules(rules)`.
|
||||
You can also choose to load circuit breaking rules later elsewhere using
|
||||
`DegradeRuleManager.loadRules(rules)` API of Sentinel, or via Sentinel dashboard.
|
||||
|
||||
===== Reactive Example
|
||||
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
@Bean
|
||||
public Customizer<ReactiveSentinelCircuitBreakerFactory> defaultCustomizer() {
|
||||
return factory -> factory.configureDefault(id -> new SentinelConfigBuilder(id)
|
||||
.build());
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
==== Specific Circuit Breaker Configuration
|
||||
|
||||
Similarly to providing a default configuration, you can create a `Customizer` bean this is passed a
|
||||
`SentinelCircuitBreakerFactory`.
|
||||
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
@Bean
|
||||
public Customizer<SentinelCircuitBreakerFactory> slowCustomizer() {
|
||||
String slowId = "slow";
|
||||
List<DegradeRule> rules = Collections.singletonList(
|
||||
new DegradeRule(slowId).setGrade(RuleConstant.DEGRADE_GRADE_RT)
|
||||
.setCount(100)
|
||||
.setTimeWindow(10)
|
||||
);
|
||||
return factory -> factory.configure(builder -> builder.rules(rules), slowId);
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
===== Reactive Example
|
||||
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
@Bean
|
||||
public Customizer<ReactiveSentinelCircuitBreakerFactory> customizer() {
|
||||
List<DegradeRule> rules = Collections.singletonList(
|
||||
new DegradeRule().setGrade(RuleConstant.DEGRADE_GRADE_RT)
|
||||
.setCount(100)
|
||||
.setTimeWindow(10)
|
||||
);
|
||||
return factory -> factory.configure(builder -> builder.rules(rules), "foo", "bar");
|
||||
}
|
||||
----
|
||||
====
|
Before Width: | Height: | Size: 165 KiB |
Before Width: | Height: | Size: 69 KiB |
Before Width: | Height: | Size: 2.0 MiB |
Before Width: | Height: | Size: 2.0 MiB |
Before Width: | Height: | Size: 1.9 MiB |
Before Width: | Height: | Size: 1.9 MiB |
Before Width: | Height: | Size: 1.9 MiB |
Before Width: | Height: | Size: 2.4 MiB |
Before Width: | Height: | Size: 156 KiB |
@ -1,87 +0,0 @@
|
||||
== Spring Cloud Alibaba Seata
|
||||
|
||||
=== Introducing Seata
|
||||
|
||||
Seata is a distributed transaction framework to ensure the data consistency of each service under the microservice architecture.
|
||||
|
||||
|
||||
=== How to use seata
|
||||
|
||||
|
||||
To include Seata in your project, use the starter with group ID `com.alibaba.cloud` and artifact ID `spring-cloud-starter-alibaba-seata`.
|
||||
|
||||
[source,xml]
|
||||
----
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
|
||||
</dependency>
|
||||
----
|
||||
|
||||
The project provides relevant https://github.com/alibaba/spring-cloud-alibaba/tree/2.2.x/spring-cloud-alibaba-examples/seata-example[Example], before running it, you need to complete the following steps:
|
||||
|
||||
1. Ensure that `nacos-server` is running locally on the `8848` port.
|
||||
2. Configuration database, will application in the resources directory of the `account-server`, `order-service`, `storage-service` three applications. The following configuration in the yml file is modified to the actual configuration in your running environment.
|
||||
|
||||
base:
|
||||
config:
|
||||
mdb:
|
||||
hostname: 127.0.0.1 #your mysql server ip address
|
||||
dbname: seata #your database name for test
|
||||
port: 3306 #your mysql server listening port
|
||||
username: root #your mysql server username
|
||||
password: root #your mysql server password
|
||||
|
||||
3. Create the database tables, you can refer to `all.sql` under `spring-cloud-alibaba-examples/seata-example` for a quick operation.
|
||||
- According to the selected transaction mode, create a https://github.com/seata/seata/tree/develop/script/client[transaction log table]. For example, the default is AT mode, then enter at/db and select the corresponding database script executes
|
||||
- Create a https://github.com/seata/seata/tree/develop/script/server/db[status record table] related to seata transactions, including `global_table` , `branch_table` , `lock_table` , `distributed_lock`.
|
||||
- Create the database tables required by `spring-cloud-alibaba-examples/seata-example` .
|
||||
4. Create the Nacos configuration in `spring-cloud-alibaba-examples/seata-example` .
|
||||
|
||||
data id: seata.properties,
|
||||
Group: SEATA_ Group(Seata 1.5.1 default group)
|
||||
|
||||
Configuration Content:
|
||||
service.vgroupMapping.order-service-tx-group=default
|
||||
service.vgroupMapping.account-service-tx-group=default
|
||||
service.vgroupMapping.business-service-tx-group=default
|
||||
service.vgroupMapping.storage-service-tx-group=default
|
||||
|
||||
5. Start Seata Server This describes SpringBoot and download server in two ways.
|
||||
- Run seata-server from `spring-cloud-alibaba-examples/seata-example` to start Seata server.
|
||||
- Run https://seata.io/zh-cn/docs/ops/deploy-guide-beginner.html[seata-server.jar] provided by official website to start Seata server.
|
||||
6. Start the sub-services under the `spring-cloud-alibaba-examples/seata-example` including `account-service` , `order-service` , `storage-service` , and finally start the global transaction control service `business-service`。
|
||||
7. After launching the example, the following URLs are accessed through the GET method of HTTP to validate scenarios where other services are invoked through RestTemplate and FeignClient in `business-service` respectively.
|
||||
|
||||
http://127.0.0.1:18081/seata/feign
|
||||
http://127.0.0.1:18081/seata/rest
|
||||
|
||||
=== Seata Dashboard
|
||||
|
||||
- Seata 1.5.1 supports Seata console 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.
|
||||
|
||||
|
||||
=== How do I verify the success of a distributed transaction?
|
||||
==== Whether Xid information was successfully transmitted
|
||||
|
||||
In the Controller of the three services `account-server`, `order-service` and `storage-service`, the first logic executed is to output the Xid information in the RootContext. If you see that the correct Xid information is output, it changes every time and the Xid of all services in the same call is consistent. This indicates that the transfer and restore of Seata's Xid are normal.
|
||||
|
||||
==== Consistency of data in database
|
||||
|
||||
In this example, we simulate a scenario where a user purchases goods, StorageService is responsible for deducting the inventory quantity, OrderService is responsible for saving the order, and AccountService is responsible for deducting the user account balance.
|
||||
|
||||
To demonstrate the sample, we used Random in OrderService and AcountService. NextBoolean () randomly throws exceptions, simulating a scenario in which exceptions occur randomly when a service is invoked.
|
||||
|
||||
If the distributed transaction is valid, then the following equation should be true
|
||||
|
||||
- User Original Amount (1000) = User Existing Amount + Goods Unit Price (2) * Order Quantity * Goods Quantity per Order (2)
|
||||
- Initial Quantity of Goods (100) = Existing Quantity of Goods + Order Quantity * Quantity of Goods per Order (2)
|
||||
|
||||
=== Support points for Spring Cloud
|
||||
|
||||
- Service providers that provide services through Spring MVC can automatically restore the Seata context when they receive HTTP requests with Seata information in the header.
|
||||
- Support for automatic delivery of Seata context when service callers invoke through RestTemplate.
|
||||
- Supports automatic delivery of the Seata context when a service caller invokes through a FeignClient.
|
||||
- Supports scenarios where both SeataClient and Hystrix are used.
|
||||
- Supports scenarios used by both SeataClient and Sentinel.
|
@ -1,34 +0,0 @@
|
||||
[[spring-cloud-alibaba-reference]]
|
||||
= Spring Cloud Alibaba Reference Documentation
|
||||
Jim Fang, Jing Xiao, Mercy Ma, Xiaolong Zuo, Bingting Peng, Yuxin Wang
|
||||
:doctype: book
|
||||
:toc:
|
||||
:toclevels: 4
|
||||
:source-highlighter: prettify
|
||||
:numbered:
|
||||
|
||||
include::introduction.adoc[]
|
||||
|
||||
include::dependency-management.adoc[]
|
||||
|
||||
include::nacos-discovery.adoc[]
|
||||
|
||||
include::nacos-config.adoc[]
|
||||
|
||||
include::sentinel.adoc[]
|
||||
|
||||
include::rocketmq.adoc[]
|
||||
|
||||
include::ans.adoc[]
|
||||
|
||||
include::acm.adoc[]
|
||||
|
||||
include::oss.adoc[]
|
||||
|
||||
include::schedulerx.adoc[]
|
||||
|
||||
include::sms.adoc[]
|
||||
|
||||
include::appactive.adoc[]
|
||||
|
||||
include::governance.adoc[]
|