You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2019/02/19 14:07:46 UTC

[servicecomb-pack] branch master updated: [SCB-1151] Add Eureka integration Chinese description & error correction (#405)

This is an automated email from the ASF dual-hosted git repository.

ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-pack.git


The following commit(s) were added to refs/heads/master by this push:
     new fa61ffc  [SCB-1151] Add Eureka integration Chinese description & error correction (#405)
fa61ffc is described below

commit fa61ffc2e1ed7554985b71906bd0842d563e967f
Author: Lei Zhang <co...@gmail.com>
AuthorDate: Tue Feb 19 22:07:42 2019 +0800

    [SCB-1151] Add Eureka integration Chinese description & error correction (#405)
    
    
    * [SCB-1151] Add Eureka integration Chinese description
    
    * [SCB-1151] Add Eureka integration Chinese description
    
    * [SCB-1151] Add Eureka configuration
    
    * [SCB-1151] Add eureka configuration description
---
 README.md                                          |   6 +-
 README_ZH.md                                       |   8 +-
 .../how_to_use_mysql_as_alpha_backend_database.md  |   6 +-
 .../how_to_use_mysql_as_alpha_backend_database.md  |   3 +
 docs/user_guide.md                                 |   2 +-
 docs/user_guide_zh.md                              | 104 +++++++++++++++++++--
 6 files changed, 111 insertions(+), 18 deletions(-)

diff --git a/README.md b/README.md
index 0d548df..bbf0e2b 100644
--- a/README.md
+++ b/README.md
@@ -45,10 +45,10 @@ Now we have different lanaguage implementation of Omega
    ```bash
       $ mvn clean install -DskipTests=true -Pdemo,docker
    ```     
-* Current ServiceComb Pack code supports Spring Boot 1.x and Spring Boot 2.x at the same time, saga uses Spring Boot 1.x by default, you can use *-Pspring-boot-2* to switch Spring Boot version to 2.x.
-Since Spring Boot supports JDK9 since 2.x, if you want to build and run test the Saga with JDK9 or JDK10, you need to use the spring-boot-2 profile. 
+* Current ServiceComb Pack code supports Spring Boot 1.x and Spring Boot 2.x at the same time, saga uses Spring Boot 2.x by default, you can use *-Pspring-boot-1* to switch Spring Boot version to 2.x.
+Since Spring Boot supports JDK9 since 2.x, if you want to build and run test the Saga with JDK9 or JDK10, please don't use the spring-boot-1 profile. 
    ```bash
-      $ mvn clean install -Pdemo,docker,spring-boot-2
+      $ mvn clean install -Pdemo,docker,spring-boot-1
    ```   
 
 ## User Guide
diff --git a/README_ZH.md b/README_ZH.md
index 2887b6b..89179df 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -48,11 +48,11 @@ ServiceComb Pack 架构是由 **alpha** 和 **omega**组成,其中:
    ```bash
       $ mvn clean install -DskipTests=true -Pdemo,docker
    ```       
-* 当前ServiceComb Pack同时支持Spring Boot 1.x以及Spring Boot 2.x,在缺省情况下ServiceComb Pack会使用Spring Boot 1.x来进行构建。
-你可以使用 *-Pspring-boot-2* 将Spring Boot版本转换到 2.x 上。 由于Spring Boot 只在2.x开始支持 JDK9,如果你想用
-JDK9或者JDK10来编译Saga并运行测试的话,你需要使用spring-boot-2 profile参数。
+* 当前ServiceComb Pack同时支持Spring Boot 1.x以及Spring Boot 2.x,在缺省情况下ServiceComb Pack会使用Spring Boot 2.x来进行构建。
+你可以使用 *-Pspring-boot-1* 将Spring Boot版本转换到 1.x 上。 由于Spring Boot 只在2.x开始支持 JDK9,如果你想用
+JDK9或者JDK10来编译Saga并运行测试的话,请不要使用spring-boot-1 profile参数。
    ```bash
-      $ mvn clean install -Pdemo,docker,spring-boot-2
+      $ mvn clean install -Pdemo,docker,spring-boot-1
    ```
 
 ## 用户指南
diff --git a/docs/faq/cn/how_to_use_mysql_as_alpha_backend_database.md b/docs/faq/cn/how_to_use_mysql_as_alpha_backend_database.md
index 66b2ab7..f0cc62c 100644
--- a/docs/faq/cn/how_to_use_mysql_as_alpha_backend_database.md
+++ b/docs/faq/cn/how_to_use_mysql_as_alpha_backend_database.md
@@ -30,13 +30,15 @@
 4. 运行alpha。请确保MySQL在此前已成功启动。alpha的运行可通过docker或可执行文件的方式。
    * 通过docker
       ```bash
-      docker run -d -p 8080:8080 -p 8090:8090 -e "JAVA_OPTS=-Dspring.profiles.active=mysql -Dspring.datasource.url=jdbc:mysql://${host_address}:3306/saga?useSSL=false" alpha-server:${saga_version}
+      docker run -d -p 8080:8080 -p 8090:8090 -e "JAVA_OPTS=-Dspring.profiles.active=mysql -Dspring.datasource.url=jdbc:mysql://${host_address}:3306/saga?serverTimezone=GMT%2b8&useSSL=false" alpha-server:${saga_version}
       ```
    * 通过可执行文件
       ```bash
-      java -Dspring.profiles.active=mysql -D"spring.datasource.url=jdbc:mysql://${host_address}:3306/saga?useSSL=false" -jar alpha-server-${saga_version}-exec.jar
+      java -Dspring.profiles.active=mysql -D"spring.datasource.url=jdbc:mysql://${host_address}:3306/saga?serverTimezone=GMT%2b8&useSSL=false" -jar alpha-server-${saga_version}-exec.jar
       ```
    **注意**: 请在运行命令前将`${saga_version}`和`${host_address}`更改为实际值。
 
    **注意**: 默认情况下,8080端口用于处理omega处发起的gRPC的请求,而8090端口用于处理查询存储在alpha处的事件信息。
+   
+   **注意**: 请确保MySQL连接串中设置了正确的时区参数`serverTimezone=GMT%2b8`。
 
diff --git a/docs/faq/en/how_to_use_mysql_as_alpha_backend_database.md b/docs/faq/en/how_to_use_mysql_as_alpha_backend_database.md
index c63a1de..b494866 100644
--- a/docs/faq/en/how_to_use_mysql_as_alpha_backend_database.md
+++ b/docs/faq/en/how_to_use_mysql_as_alpha_backend_database.md
@@ -41,3 +41,6 @@
 
 
    **Note**: By default, port 8080 is used to serve omega's request via gRPC while port 8090 is used to query the events stored in alpha.
+   
+   
+   **Note**: Please configuration serverTimezone property in MySQL connection string
diff --git a/docs/user_guide.md b/docs/user_guide.md
index ce83251..94aae07 100644
--- a/docs/user_guide.md
+++ b/docs/user_guide.md
@@ -208,7 +208,7 @@ Add TCC annotations and corresponding confirm and cancel methods
        address: {alpha.cluster.addresses}
    ```
 
-Then you can start your micro-services and access all saga events via http://${alpha-server:port}/events.
+Then you can start your micro-services and access all saga events via http://${alpha-server:port}/saga/events.
 
 ## Enable SSL for Alpha and Omega
 
diff --git a/docs/user_guide_zh.md b/docs/user_guide_zh.md
index 2b13f79..6e7c200 100644
--- a/docs/user_guide_zh.md
+++ b/docs/user_guide_zh.md
@@ -132,8 +132,8 @@ Saga可通过以下任一方式进行构建:
         SpringApplication.run(Application.class, args);
       }
     }
-    ```
-    
+   ```
+   
 2. 在全局事务的起点添加 `@TccStart` 的注解。
     ```java
     import org.apache.servicecomb.pack.omega.context.annotations.TccStart;
@@ -145,12 +145,12 @@ Saga可通过以下任一方式进行构建:
     }
     ```
     **Note:** 当前TCC还不支持Timeout
- 
+
 3. 在子事务尝试方法处添加 `@Participate` 的注解并指明其对应的执行以及补偿方法名, 
     ```java
     import javax.transaction.Transactional;
     import org.apache.servicecomb.pack.omega.transaction.annotations.Participate;
-   
+      
     @Participate(confirmMethod = "confirm", cancelMethod = "cancel")
     @Transactional
     public void transferOut(String from, int amount) {
@@ -161,17 +161,17 @@ Saga可通过以下任一方式进行构建:
     public void confirm(String from, int amount) {
       repo.reduceBalanceByUsername(from, amount);
     }
-  
+    
     @Transactional
     public void cancel(String from, int amount) {
       repo.addBalanceByUsername(from, amount);
     }
     ```
- 
+
     **Note:** The confirm and cancel method should have same arguments with participate method, confirm and cancel method implemented by services must be idempotent. We highly recommend to use the Spring @Transactional to guarantee the local transaction.
    
     **Note:** 若全局事务起点与子事务起点重合,需同时声明 `@TccStart`  和 `@Participate` 的注解。 
- 
+
 4. 对转入服务重复第三步即可。
 
 5. 从pack-0.3.0开始, 你可以在服务函数或者取消函数中通过访问 [OmegaContext](https://github.com/apache/servicecomb-pack/blob/master/omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/OmegaContext.java) 来获取 gloableTxId 以及 localTxId 信息。
@@ -211,4 +211,92 @@ Saga可通过以下任一方式进行构建:
        address: {alpha.cluster.addresses}
    ```
 
-然后就可以运行相关的微服务了,可通过访问http://${alpha-server:port}/events 来获取所有的saga事件信息。
+然后就可以运行相关的微服务了,可通过访问http://${alpha-server:port}/saga/events 来获取所有的saga事件信息。
+
+### 注册中心支持
+
+支持Alpha启动时自动注册到注册中心,Omega通过注册中心获取Alpha的实例列表和gRPC地址
+
+#### Spring Cloud Eureka支持
+
+1. 编译Alpha的Eureka的版本
+
+   在编译时增加`spring-cloud-eureka`参数
+
+   ```bash
+   git clone https://github.com/apache/servicecomb-pack.git
+   cd servicecomb-pack
+   mvn clean install -DskipTests=true -Pspring-cloud-eureka
+   ```
+
+   **注意:** 默认情况下,编译的版本兼容spring boot 2.x,当使用omega的项目是基于spring boot 1.x时请在编译的时使用`-Pspring-cloud-eureka,spring-boot-1`参数
+
+   
+
+2. 运行alpha
+
+   运行是增加`spring.profiles.active=spring-cloud-eureka`参数
+
+   ```bash
+   java -Dspring.profiles.active=prd -D"spring.datasource.url=jdbc:postgresql://${host_address}:5432/saga?useSSL=false" -jar alpha-server-${saga_version}-exec.jar --spring.profiles.active=spring-cloud-eureka
+   ```
+
+3. 验证是否注册成功
+
+   访问Eureka的注册实例查询接口`curl http://127.0.0.1:8761/eureka/apps/`可以看到如下注册信息,在你metadata中可以看到Alpha的gRPC访问地址`<servicecomb-alpha-server>0.0.0.0:8080</servicecomb-alpha-server>`已经注册
+
+   ```xml
+   <applications>
+     <versions__delta>1</versions__delta>
+     <apps__hashcode>UP_1_</apps__hashcode>
+     <application>
+       <name>SERVICECOMB-ALPHA-SERVER</name>
+       <instance>
+         <instanceId>0.0.0.0::servicecomb-alpha-server:8090</instanceId>
+         <hostName>0.0.0.0</hostName>
+         <app>SERVICECOMB-ALPHA-SERVER</app>
+         <ipAddr>0.0.0.0</ipAddr>
+         <status>UP</status>
+   	  ...
+         <metadata>
+           <management.port>8090</management.port>
+           <servicecomb-alpha-server>0.0.0.0:8080</servicecomb-alpha-server>
+         </metadata>
+         ...
+       </instance>
+     </application>
+   </applications>
+   ```
+
+   **注意:** 默认情况下注册的服务名是`SERVICECOMB-ALPHA-SERVER`,如果你需要自定义服务名可以在运行Alpha的时候通过命令行参数`spring.application.name`配置
+
+4. 配置omega
+
+   在项目中引入依赖包`omega-spring-cloud-starter`
+
+   ```xml
+   <dependency>
+   	<groupId>org.apache.servicecomb.pack</groupId>
+   	<artifactId>omega-spring-cloud-starter</artifactId>
+   	<version>${pack.version}</version>
+   </dependency>
+   ```
+
+   在 `application.yaml` 添加下面的配置项:
+
+   ```yaml
+   eureka:
+     client:
+       service-url:
+         defaultZone: http://127.0.0.1:8761/eureka
+   alpha:
+     cluster:
+       register:
+         type: spring-cloud
+   ```
+
+   * `eureka.client.service-url.defaultZone` 配置Eureka注册中心的地址,其他Eureka客户端配置可以参考[Spring Cloud Netflix 2.x](https://cloud.spring.io/spring-cloud-netflix/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter) 或 [Spring Cloud Netflix 1.x](https://cloud.spring.io/spring-cloud-netflix/1.4.x/multi/multi__service_discovery_eureka_clients.html#netflix-eureka-client-starter)
+   * `alpha.cluster.register.type=spring-cloud` 配置Omega获取Alpha的方式是通过Eureka的注册中心
+
+   **注意:** 如果你在启动Alpha的时候通过命令行参数`spring.application.name`自定义了服务名,那么那么你需要在Omega中通过参数`alpha.cluster.serviceId`指定这个服务名
+