Skip to content

xk-dragonfly/xk-RPC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Distributed xk-RPC System

Java Spring Boot Netty Zookeeper Nacos License: MIT

A distributed RPC (Remote Procedure Call) system implemented using Spring Boot, Netty, and Zookeeper. The system allows for service registration and discovery, enabling efficient communication between distributed services. The system supports customizable components, with Zookeeper for service registration (which can be replaced by Nacos) and Netty for communication (which can be switched to the HTTP protocol).

Features

  • Service Registration and Discovery: Utilizes Zookeeper for managing service instances. Nacos can be used as an alternative.
  • RPC Communication: Uses Netty for fast, asynchronous communication. Alternatively, the HTTP protocol can be used for simplicity and ease of integration.
  • Scalability: Designed to support large-scale distributed environments with multiple services.
  • Spring Boot Integration: Leverages Spring Boot for dependency management, configuration, and ease of use.

Getting Started

Prerequisites

  • Java 17 or higher
  • Maven
  • Zookeeper (or Nacos if preferred)
  • Netty (or HTTP if preferred)

Installation

  1. Clone the repository:

    git clone https://github.com/xk-dragonfly/xk-RPC.git
  2. Configure Zookeeper:

    Install and start a Zookeeper instance locally or use an existing one. Update the application.yml or application.properties file with the Zookeeper connection string:

    zookeeper:
      connect-string: localhost:2181

    If using Nacos, update the configuration accordingly:

    nacos:
      server-addr: localhost:8848
  3. Build and Run the Application:

    Use Maven or Gradle to build and start the consumer and provider modules:

    # Start the Provider module
    cd provider
    mvn clean install
    mvn spring-boot:run

    or

    # Start the Consumer module
    cd ../consumer
    mvn clean install
    mvn spring-boot:run

Configuration

  • Switching to HTTP Protocol: To replace Netty with HTTP, adjust the communication-related classes to use RestTemplate or WebClient from Spring.

  • Using Nacos for Service Registration: Replace Zookeeper's configuration with Nacos. Update the dependencies and service registration logic accordingly.

Example Usage

  • Service Registration: A service can register itself with Zookeeper or Nacos by defining a unique service name and endpoint.
  • Service Discovery: Services can discover other registered services by querying Zookeeper or Nacos.
  • Remote Procedure Call: The client can invoke methods on remote services as if they were local, using Netty or HTTP for communication.

Architecture Overview

  • Service Provider: Registers itself with the service registry (Zookeeper/Nacos) and listens for incoming RPC requests.
  • Service Consumer: Discovers available services from the registry and sends RPC requests.
  • Service Registry: Maintains the list of active services and their locations, facilitating service discovery.

Contributing

Contributions are welcome! Please fork the repository and create a pull request with your changes.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

For any questions or issues, please open an issue on GitHub or contact xk0708666@gmail.com.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages