Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xk-dragonfly/xk-rpc
This project provides a high-performance distributed RPC (Remote Procedure Call) system based on Spring Boot, Netty, and Zookeeper for efficient inter-service communication in microservices architectures.
https://github.com/xk-dragonfly/xk-rpc
netty rpc spring-boot zookeeper
Last synced: about 2 months ago
JSON representation
This project provides a high-performance distributed RPC (Remote Procedure Call) system based on Spring Boot, Netty, and Zookeeper for efficient inter-service communication in microservices architectures.
- Host: GitHub
- URL: https://github.com/xk-dragonfly/xk-rpc
- Owner: xk-dragonfly
- License: mit
- Created: 2024-08-17T05:35:16.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-12-27T14:45:52.000Z (about 2 months ago)
- Last Synced: 2024-12-27T15:30:05.012Z (about 2 months ago)
- Topics: netty, rpc, spring-boot, zookeeper
- Language: Java
- Homepage:
- Size: 133 KB
- Stars: 11
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# π Distributed xk-RPC System
English | [δΈζ](README_cn.md)
![Java](https://img.shields.io/badge/Java-17%2B-blue)
![Spring Boot](https://img.shields.io/badge/Spring%20Boot-2.5.2-green)
![Netty](https://img.shields.io/badge/Netty-4.1.65.Final-red)
![Zookeeper](https://img.shields.io/badge/Zookeeper-3.7.1-yellow)
![Nacos](https://img.shields.io/badge/Nacos-2.1.1-orange)
![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen)A distributed RPC (Remote Procedure Call) system built with **Spring Boot**, **Netty**, and **Zookeeper**, designed to enable efficient communication between distributed services. This highly customizable system also supports **Nacos** as a service registry and the **HTTP protocol** as an alternative to Netty.
---
## π **Features**
- π§ **Service Registration & Discovery**: Leverages Zookeeper for service management and supports Nacos as an alternative.
- β‘ **High-Performance RPC Communication**: Uses Netty for asynchronous communication, with optional HTTP support.
- π **Scalability**: Designed for large-scale distributed systems.
- β **Spring Boot Integration**: Simplifies configuration and accelerates development.---
## π οΈ **Getting Started**
### 𧩠**Prerequisites**
- βοΈ **Java 17** or higher
- βοΈ **Maven**
- βοΈ **Zookeeper** (or Nacos)
- βοΈ **Netty** (or HTTP)#### β οΈ **JDK Version Compatibility**
If using **JDK 9 or higher**, you **must** add the following JVM parameter before starting the `provider` module:
```bash
--add-opens java.base/java.lang=ALL-UNNAMED
```This prevents the following error caused by Java's modular restrictions on reflection:
```
java.lang.reflect.InaccessibleObjectException: Unable to make field 'detailMessage' accessible
```---
### π₯ **Installation**
1. **Clone the repository**
```bash
git clone https://github.com/xk-dragonfly/xk-RPC.git
```2. **Set Up Zookeeper**
Install and start a Zookeeper instance or use an existing one. Update the `application.yml` or `application.properties` configuration file:
```yaml
zookeeper:
connect-string: localhost:2181
```If you prefer to use Nacos, replace the configuration:
```yaml
nacos:
server-addr: localhost:8848
```3. **Build and Run**
Use Maven to build and start the `consumer` and `provider` modules:
```bash
# Start the Provider module
cd provider
mvn clean install
mvn spring-boot:run
``````bash
# Start the Consumer module
cd ../consumer
mvn clean install
mvn spring-boot:run
```---
## βοΈ **Configuration**
- **Switching to HTTP Protocol**: Modify communication classes to use Spring's `RestTemplate` or `WebClient`.
- **Using Nacos for Service Registration**: Update the configuration file and replace Zookeeper-related dependencies and logic.---
## π― **Example Usage**
- π **Service Registration**: Services register with Zookeeper or Nacos using a unique name and endpoint.
- π **Service Discovery**: Clients query the registry to locate and connect to services.
- π‘ **Remote Procedure Call**: Clients invoke methods on remote services seamlessly using Netty or HTTP.---
## π **Project Structure**
### π `rpc-core`
Core functionalities of the RPC system, including:- π¦ **Message Design**: Defines the structure of RPC messages.
- π **Encoding & Decoding**: Handles serialization and deserialization of messages.
- π **Service Management**: Manages service registration and discovery.
- βοΈ **Serialization**: Converts objects to transmission-ready formats.
- π― **Load Balancing**: Implements strategies to distribute workloads efficiently.---
### π» `rpc-client`
Handles client-side operations:- π **Client Proxy**: Dynamically generates proxies for remote method invocation.
- π **Communication**: Manages message transport for requests and responses.---
### π₯οΈ `rpc-server`
Manages server-side operations:- π¨ **Message Processing**: Decodes incoming messages, executes methods, and returns results.
---
### π `consumer`
Simulates the client and demonstrates how to initiate RPC calls, acting as an entry point for users.---
### ποΈ `provider`
Implements server-side services, showcasing how to register and expose methods for RPC clients.---
## π€ **Contributing**
Contributions are welcome! Please fork the repository and submit a pull request.
---
## π **License**
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
---
## π¬ **Contact**
For any questions or issues, open an issue on GitHub or email [[email protected]](mailto:[email protected]).