✈A high-performance RPC based on Java & Netty.

Overview

bRPC

GitHub license GitHub star

README 中文版本

一个基于netty的RPC框架

  1. 基于netty NIO、IO多路复用。
  2. client与server端建立心跳包保活机制。发生未知断连时,重连保证可靠长连接。
  3. 使用kryo序列化,自定义传输包,及传输格式,避免TCP沾包问题。
  4. 支持zookeeper或nacos做服务注册中心。
  5. 可在注解中配置server端业务线程池核心线程数及最大线程数,客户端可通过注解自由选择接口对应负载均衡策略。
  6. 可轻松整合SpringBoot进行使用。

Getting Start

启动

API式启动

  1. com.application.test.api.server.ServerTest.java 服务端启动
  2. com.application.test.api.client.ClientTest.java 客户端启动 并rpc调用HelloService.hello()

与SpringBoot整合启动(由于未发布到远程仓库,所以需本地maven install。)

  1. 客户端
  • maven
<dependency>
    <groupId>com.polyu</groupId>
    <artifactId>netty-client</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>
  • springboot
@Component
public class Test {

    @BRpcConsumer(version = "1.0", loadBalanceStrategy = RpcLoadBalanceConsistentHash.class, timeOutLength = 1000L)
    private static HelloService helloService;

    public static void test() throws InterruptedException {
        String yyb = helloService.hello("yyb");
        System.out.println("yyb = " + yyb);
    }
}
  • application.properties
bRPC.client.registry.type=zookeeper
bRPC.client.registry.address=127.0.0.1:2181
bRPC.client.registry.target.name=springbootApplication
bRPC.client.timeout.checkInterval=500
  1. 服务端
  • maven
<dependency>
    <groupId>com.polyu</groupId>
    <artifactId>netty-server</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>
  • springboot
@BRpcProvider(value = HelloService.class, version = "1.0")
public class HelloServiceImpl implements HelloService {
    
    @Override
    public String hello(String name) throws InterruptedException {
        return name;
    }
}
  • application.properties
bRPC.server.application.name=springbootApplication
bRPC.server.address=127.0.0.1:12277
bRPC.server.registry.type=zookeeper
bRPC.server.registry.address=127.0.0.1:2181

注册中心部署

Docker Zookeeper部署(例 同样支持nacos)

  1. 拉取zk镜像   指令:docker pull zookeeper:3.4.14
  2. 查看镜像id   指令:docker images
  3. 拉起容器    指令:docker run -d -p 2181:2181 --name b-zookeeper --restart always {imageId}
  4. 查看容器id   指令:docker ps -a
  5. 进入容器    指令:docker exec -it {containerId} /bin/bash
  6. 起注册中心   指令:./bin/zkCli.sh

A netty-based RPC framewor

  1. Based on netty NIO, IO multiplexing.
  2. The client and server establish a heartbeat packet keep-alive mechanism. When an unknown disconnection occurs, reconnection ensures a reliable long connection.
  3. Use kryo serialization, customize the transmission package, and transmission format to avoid TCP packet contamination problems.
  4. Support zookeeper or nacos as service registration center.
  5. The number of core threads and the maximum number of threads in the server-side business thread pool can be configured in the annotations, and the client can freely choose the load balancing strategy corresponding to the interface through the annotations.
  6. Can easily integrate SpringBoot for use.

Getting Start

Start

API startup

  1. com.application.test.api.server.ServerTest.java Server start
  2. com.application.test.api.client.ClientTest.java Client starts and rpc calls HelloService.hello()

Start integrated with SpringBoot (Because it is not published to a remote warehouse, it needs local maven install.)

  1. client
  • maven
<dependency>
    <groupId>com.polyu</groupId>
    <artifactId>netty-client</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>
  • springboot
@Component
public class Test {

    @BRpcConsumer(version = "1.0", loadBalanceStrategy = RpcLoadBalanceConsistentHash.class, timeOutLength = 1000L)
    private static HelloService helloService;

    public static void test() throws InterruptedException {
        String yyb = helloService.hello("yyb");
        System.out.println("yyb = " + yyb);
    }
}
  • application.properties
bRPC.client.registry.type=zookeeper
bRPC.client.registry.address=127.0.0.1:2181
bRPC.client.registry.target.name=springbootApplication
bRPC.client.timeout.checkInterval=500
  1. server
  • maven
<dependency>
    <groupId>com.polyu</groupId>
    <artifactId>netty-server</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>
  • springboot
@BRpcProvider(value = HelloService.class, version = "1.0")
public class HelloServiceImpl implements HelloService {
    
    @Override
    public String hello(String name) throws InterruptedException {
        return name;
    }
}
  • application.properties
bRPC.server.application.name=springbootApplication
bRPC.server.address=127.0.0.1:12277
bRPC.server.registry.type=zookeeper
bRPC.server.registry.address=127.0.0.1:2181

Registry deployment

Docker Zookeeper deployment (example also supports nacos)

  1. docker pull zookeeper:3.4.14
  2. docker images
  3. docker run -d -p 2181:2181 --name b-zookeeper --restart always {imageId}
  4. docker ps -a
  5. docker exec -it {containerId} /bin/bash
  6. ./bin/zkCli.sh
You might also like...

The High-Performance Java Persistence book and video course code examples

The High-Performance Java Persistence book and video course code examples

High-Performance Java Persistence The High-Performance Java Persistence book and video course code examples. I wrote this article about this repositor

Jan 9, 2023

A networking library for LibGDX utilizing Netty allowing easy creation of multiplayer games.

Lunar What is Lunar? Lunar is a networking library for LibGDX. With lunar you can easily create multiplayer games quickly and efficiently. Lunar provi

Nov 25, 2022

A fault tolerant, protocol-agnostic RPC system

A fault tolerant, protocol-agnostic RPC system

Finagle Status This project is used in production at Twitter (and many other organizations), and is being actively developed and maintained. Releases

Jan 4, 2023

Experiments on how to add Loom support for Netty

Netty Loom Experiment This repository contains Project Loom and Netty related test code. Contents / Goals I created these examples since I was curious

Oct 14, 2022

Spring-Boot-Plus is a easy-to-use, high-speed, high-efficient,feature-rich, open source spring boot scaffolding

Spring-Boot-Plus is a easy-to-use, high-speed, high-efficient,feature-rich, open source spring boot scaffolding

Everyone can develop projects independently, quickly and efficiently! What is spring-boot-plus? A easy-to-use, high-speed, high-efficient, feature-ric

Dec 31, 2022

Universal, flexible, high-performance distributed ID generator

Universal, flexible, high-performance distributed ID generator

CosId Universal, flexible, high-performance distributed ID generator 中文文档 Introduction CosId aims to provide a universal, flexible and high-performanc

Dec 27, 2022

Asynchronous, high-performance Minecraft Hologram library for 1.8-1.18 servers.

Asynchronous, high-performance Minecraft Hologram library for 1.8-1.18 servers.

Hologram-Lib Asynchronous, high-performance Minecraft Hologram library for 1.8-1.18 servers. Requirements This library can only be used on spigot serv

Dec 20, 2022

Team 5468's 2022 FRC robot code. This code is written in Java and is based off of WPILib's Java control system and utilizes a command based system

FRC 2022 Team 5468's 2022 FRC robot code. This code is written in Java and is based off of WPILib's Java control system and utilizes a command based s

Oct 4, 2022

This app/widget is based on the work of Anthony (tonesto7), which is in turn based on the earlier work of David Schablowsky

This app/widget is based on the work of Anthony (tonesto7), which is in turn based on the earlier work of David Schablowsky

Mustang Mach-E Widget for Android Intro This app/widget is based on the work of Anthony (tonesto7), which is in turn based on the earlier work of Davi

Nov 15, 2022
Owner
vincent
Back-end developer & Coding lover
vincent
💡极致性能的企业级Java服务器框架,RPC,游戏服务器框架,web应用服务器框架。(Extreme fast enterprise Java server framework, can be RPC, game server framework, web server framework.)

?? 为性能而生的万能服务器框架 ?? Ⅰ. zfoo简介 ?? 性能炸裂,天生异步,Actor设计思想,无锁化设计,基于Spring的MVC式用法的万能RPC框架 极致序列化,原生集成的目前二进制序列化和反序列化速度最快的 zfoo protocol 作为网络通讯协议 高可拓展性,单台服务器部署,

null 1k Jan 1, 2023
Lightweight service-based PubSub, RPC and public APIs in Java

kite - service-based RPC, public APIs and PubSub in Java kite is a collection of reactive application messaging libraries that aim at providing high l

teris.io 3 Feb 17, 2022
Clivia is a scalable, high-performance, elastic and responsive API gateway based on spring weblux

clivia是一款基于spring webflux的可扩展、高性能、高弹性、响应式的 API 网关 clivia_V0.0.1 架构概览 模块介绍 clivia-admin-core : 网关配置管理后台核心模块 clivia-client-core : 网关核心模块 clivia-example

palading 14 Jan 9, 2023
ActiveJ is an alternative Java platform built from the ground up. ActiveJ redefines web, high load, and cloud programming in Java, featuring ultimate performance and scalability!

Introduction ActiveJ is a full-featured modern Java platform, created from the ground up as an alternative to Spring/Micronauts/Netty/Jetty. It is des

ActiveJ LLC 579 Jan 7, 2023
A base repo for creating RPC microservices in Java with gRPC, jOOQ, and Maven.

Wenower Core OSX local installation Install Protocol Buffer $ brew install protobuf Install Postgresql and joopc database and user $ brew install pos

Hamidreza Soleimani 1 Jan 9, 2022
A implementation of shadowsocks that base on java's netty framework

Shadowsocks shadowsocks is a fast tunnel proxy that helps you bypass firewalls. shadowsocks-java is a implementation of shadowsocks protocol that base

bigbyto 36 Oct 17, 2022
High Performance data structures and utility methods for Java

Agrona Agrona provides a library of data structures and utility methods that are a common need when building high-performance applications in Java. Ma

Real Logic 2.5k Jan 7, 2023
ShenYu is High-Performance Java API Gateway.

Scalable, High Performance, Responsive API Gateway Solution for all MicroServices https://shenyu.apache.org/ English | 简体中文 Architecture Features Shen

The Apache Software Foundation 7.5k Jan 4, 2023
A modular, high performance, headless e-commerce(ecommerce) platform built with Java,Springboot, Vue.

What is Shopfly? Shopfly is modular, high performance, headless e-commerce(ecommerce) platform built with Java,Springboot, Vue. Architecture Shopfly i

Shopfly 31 Jul 17, 2022
A modular, high performance, headless e-commerce(ecommerce) platform built with Java,Springboot, Vue.

What is Shopfly? Shopfly is modular, high performance, headless e-commerce(ecommerce) platform built with Java,Springboot, Vue. Architecture Shopfly i

Shopfly 29 Apr 25, 2022