Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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]).