# demos-bytetcc **Repository Path**: Habens/demos-bytetcc ## Basic Information - **Project Name**: demos-bytetcc - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-03-20 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # demos-bytetcc 利用`bytetcc`实践分布式事务的处理。 ### 待解决问题 2个用户(处于两个业务系统之中)之间转账功能的接口及其内部实现 ### 实现说明 #### 1. eureka-server 服务注册中心:下面的几个服务都会注册在这个服务注册中心,用于各个服务间的相互发现 启动方式: ``` ./gradlew bootRun ``` 访问地址:[http://localhost:8082](http://localhost:8082) #### 2. remitter 汇款账户所在系统,通过 `/transfer` 来把资金从本地数据库转到 `receiver` 的数据库。 启动方式: ```shell docker-compose --file docker/docker-compose.yml up -d ./gradlew bootRun ``` 访问地址:[http://localhost:8080](http://localhost:8080) #### 3. receiver 收款账户所在系统,暴露 `/increaseAmount` 给 `remitter`,用于收款。 启动方式: ``` docker-compose --file docker/docker-compose.yml up -d ./gradlew bootRun ``` 访问地址:[http://localhost:8081](http://localhost:8081) #### 4. api-gateway 使用 Spring cloud zuul 做的网关,意图是用来做这几个微服务的 `authentication` 和 所有微服务的一个入口。 只有通过了`authentication`才可以继续调用之后的转账功能。这里只是实现了一个假的 `authentication`。只要访问的这个网关的连接上有 `accessToken` 参数都可以通过。 比如,访问 [localhost:8083/transfer?accessToken=fake-token](localhost:8083/transfer?accessToken=fake-token), `api-gateway`会把这个请求转到转到 `remitter` 系统上的 `/transfer` 接口。 启动方式: ``` ./gradlew bootRun ``` 访问地址:[http://localhost:8083](http://localhost:8083) ### 测试: * 直接访问 `remitter`:[http://localhost:8080/transfer](http://localhost:8080/transfer) * 通过`api-gateway`访问:[http://localhost:8083/transfer?accessToken=fake-token](http://localhost:8083/transfer?accessToken=fake-token) request body 都为: ```json { "remitterAccountId": "1", "receiverAccountId": "2", "amount": 100 } ```