diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000000000000000000000000000000000000..e5424c041dd18ec1a7740b6aaca0d0a57e247324 --- /dev/null +++ b/README.en.md @@ -0,0 +1,88 @@ + + +# Spring Cloud Alibaba Sample Project + +This is a collection of microservices projects built using the Spring Cloud Alibaba technology stack, primarily integrating Nacos for service discovery and Sentinel for traffic control. It is suitable for learning and practicing distributed service architectures. + +## Project Overview + +This project contains multiple modules, demonstrating the use of Nacos as a service registration and discovery center, as well as Sentinel's application in service rate limiting and degradation. + +### Module Descriptions + +- `cloudalibaba-consumer-nacos-consumer8000`: A service consumer based on Nacos, using Feign for remote calls and integrating Sentinel to implement service protection. +- `cloudalibaba-sentinel-provider9001` / `cloudalibaba-sentinel-provider9002`: Two providers offering product services, used to demonstrate load balancing and service invocation. +- `cloudalibaba-sentinel-service8000`: A service integrated with Sentinel, showcasing various rate limiting and hot parameter control strategies. +- `nacos-client7777`: A Nacos configuration center client, supporting dynamic configuration refresh. +- `nacos-consumer9000`: Another service consumer based on Nacos, using RestTemplate and Feign for service calls. +- `nacos-provider8000` / `nacos-provider8001`: Nacos service providers, offering product query interfaces. + +## Technology Stack + +- Spring Boot +- Spring Cloud Alibaba +- Nacos (service discovery and configuration management) +- Sentinel (traffic control, circuit breaking, and degradation) +- Feign (declarative service invocation) +- LoadBalancer (client-side load balancing) + +## Quick Start + +### Dependencies + +Ensure the following components are installed: + +- Java 1.8 or higher +- Maven +- Nacos Server +- Sentinel Dashboard (optional) + +### Starting the Services + +1. Start the Nacos Server. +2. Start the following service modules in sequence: + - `cloudalibaba-sentinel-provider9001` + - `cloudalibaba-sentinel-provider9002` + - `nacos-provider8000` + - `nacos-provider8001` +3. Start the consumer modules: + - `cloudalibaba-consumer-nacos-consumer8000` + - `nacos-consumer9000` + - `cloudalibaba-sentinel-service8000` +4. Start `nacos-client7777` to test the configuration center functionality. + +## Usage Examples + +### Service Invocation + +Access the following URLs to trigger service calls: + +- `http://localhost:8000/order/add/1`: Invokes the product service to retrieve product information. +- `http://localhost:9000/order/add/1`: Invokes the service provider interface using RestTemplate. + +### Rate Limiting and Degradation + +The `cloudalibaba-sentinel-service8000` module demonstrates Sentinel's rate limiting features: + +- `http://localhost:8000/testA`: A basic rate limiting interface. +- `http://localhost:8000/testB`: Demonstrates integration of load balancing with rate limiting. +- `http://localhost:8000/order`: A hot parameter rate limiting interface, using `goodsId` and `userId` as parameters. + +### Dynamic Configuration + +The `nacos-client7777` module demonstrates the dynamic configuration refresh capability of the Nacos configuration center: + +- `http://localhost:7777/config/name`: Returns the `name` property from the configuration center. + +## Contribution Guide + +We welcome code contributions! Please follow these steps: + +1. Fork the project +2. Create a new branch +3. Commit your changes +4. Create a Pull Request + +## License + +This project is licensed under the MIT License. For details, please refer to the LICENSE file in the root directory. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a942725c2f64b7902e68a6ac48d3bc350a7c8263 --- /dev/null +++ b/README.md @@ -0,0 +1,88 @@ + + +# Spring Cloud Alibaba 示例项目 + +这是一个使用 Spring Cloud Alibaba 技术栈构建的微服务项目集合,主要集成了 Nacos 服务发现与 Sentinel 流量控制,适用于分布式服务架构的学习与实践。 + +## 项目概述 + +本项目包含多个模块,演示了 Nacos 作为服务注册与发现中心,以及 Sentinel 在服务限流、降级方面的应用。 + +### 模块说明 + +- `cloudalibaba-consumer-nacos-consumer8000`:基于 Nacos 的服务消费者,使用 Feign 进行远程调用并集成 Sentinel 实现服务保护。 +- `cloudalibaba-sentinal-provider9001` / `cloudalibaba-sentinal-provider9002`:提供商品服务的两个提供者,用于演示负载均衡和服务调用。 +- `cloudalibaba-sentinel-service8000`:集成 Sentinel 的服务,展示了多种限流和热点参数控制策略。 +- `nacos-client7777`:Nacos 配置中心客户端,支持配置的动态刷新。 +- `nacos-conusmer9000`:另一个基于 Nacos 的服务消费者,使用 RestTemplate 和 Feign 进行服务调用。 +- `nacos-provider8000` / `nacos-provider8001`:Nacos 服务提供者,提供商品查询接口。 + +## 技术栈 + +- Spring Boot +- Spring Cloud Alibaba +- Nacos(服务发现与配置中心) +- Sentinel(流量控制、熔断降级) +- Feign(声明式服务调用) +- LoadBalancer(客户端负载均衡) + +## 快速开始 + +### 启动依赖 + +确保你已安装以下组件: + +- Java 1.8 或更高版本 +- Maven +- Nacos Server +- Sentinel Dashboard(可选) + +### 启动服务 + +1. 启动 Nacos Server。 +2. 分别启动以下服务模块: + - `cloudalibaba-sentinal-provider9001` + - `cloudalibaba-sentinal-provider9002` + - `nacos-provider8000` + - `nacos-provider8001` +3. 启动消费者模块: + - `cloudalibaba-consumer-nacos-consumer8000` + - `nacos-conusmer9000` + - `cloudalibaba-sentinel-service8000` +4. 启动 `nacos-client7777` 以测试配置中心功能。 + +## 使用示例 + +### 服务调用 + +访问以下 URL 以触发服务调用: + +- `http://localhost:8000/order/add/1`:调用商品服务获取商品信息。 +- `http://localhost:9000/order/add/1`:通过 RestTemplate 调用服务提供者接口。 + +### 限流与降级 + +`cloudalibaba-sentinel-service8000` 模块演示了 Sentinel 的限流功能: + +- `http://localhost:8000/testA`:基础限流接口。 +- `http://localhost:8000/testB`:演示负载均衡与限流结合。 +- `http://localhost:8000/order`:热点参数限流接口,使用 `goodsId` 和 `userId` 作为参数。 + +### 动态配置 + +`nacos-client7777` 模块演示了 Nacos 配置中心的动态配置刷新功能: + +- `http://localhost:7777/config/name`:返回配置中心的 `name` 属性。 + +## 贡献指南 + +欢迎贡献代码!请遵循以下步骤: + +1. Fork 项目 +2. 创建新分支 +3. 提交你的修改 +4. 创建 Pull Request + +## 许可证 + +本项目采用 MIT 许可证。详情请查看根目录的 LICENSE 文件。 \ No newline at end of file