Skip to content
A naive rpc framework in java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


NaiveRpc is a project base on java language development. It is an Rpc(Remote Procedure Call) framework based on Netty, Zookeeper and Spring. Because of the poor level of myself, I call it naiverpc.

Read more

Author Flying Cat


  • Transport in netty
  • Serialization in kryo
  • Service register center is ZooKeeper
  • Support BIO and NO-BIO(similar Class Future<T> in Java) call
  • Spring integration


Quick Start

Maven dependency



NaiveRpc supports can use in api and spring.

Assume there is an interface

package demo.rpc;
public interface SayHello{
    String sayHelloToOne(String one);

And next is an implement class.

public class SayHelloImpl implements SayHello{
    public String sayHelloToOne(String one){
        return "Hello!" + one;

We can use it like this.


 * Start Server
ProviderPublisher provider = new ProviderPublisher.Builder("", 9000,
                SayHello.class, new SayHelloImpl()).build();

 * Start Client
ConsumerProxy consumser = new ConsumerProxy.Builder("",

 * Sync
SayHello sayHello = consumer.callSync();
System.out.println(sayHello.sayHelloToOne("Li Hua"));

 * Async
ProxyFactory proxyFactory = consumerProxy.callAsync();
RpcFuture rpcFuture ="sayHelloToOne", new Object[]{"world"});
//Somethind need to do


 * Server
 <bean id="springProviderPublisher" class="gq.shiwenhao.naiverpc.endpoint.SpringProviderPublisher">
    <property name="zookeeperHost" value=""/>
    <property name="interfaceClassName" value="demo.rpc.SayHello"/>
    <property name="interfaceImpl">
       <bean class="SayHelloImpl"/>
    <property name="port" value="9000"/>

 * Client
 <bean id = "springConsumerProxy" class="gq.shiwenhao.naiverpc.endpoint.SpringConsumerProxy">
     <property name="zookeeperHost" value=""/>
     <property name="interfaceClassName" value="demo.rpc.SayHello"/>
     <!--property name="async" value="true"-->
  * Sync call (if async is false, default)
SayHello sayHello = (SayHello) beanFactory.getBean("springConsumerProxy");
System.out.println(sayHello.sayHelloToOne("Li Hua"));

 * Async call (if async is true)
ProxyFactory proxyFactory = (ProxyFactory) beanFactory.getBean("springConsumerProxy");
RpcFuture rpcFuture ="sayHelloToOne", new Object[]{"World"});

It is easy. If you want to know more, please git clone the repositry and observery the test code. It has a demo of using naive-rpc includes api and spring.


  • Client
Property Parameter comment
must ZookeeperHost(String) Zookeeper server address
must InterfaceClass(String/Class) Interface class
optional LoadBalanceEnum LoadBalanceEnum.Random,WeightRandom,Polling,WeightPolling,Random Deafult
optional RetryRequest(Boolean)
optional RetryTimes(int)
optional Timeout(int /ms)
  • Server
Property Parameter comment
must ZookeeperHost(String) Zookeeper server address
must port(int) Listen port
must InterfaceClass(String/Class) Interface class
must InterfaceImpl(Object) Impl Object
optional weight(int) Server load balance weight, Default 1
optional MaxRequestMessageLength(int) Default 65535, default is ok


  • Optimize parameters set method of Spring
  • Mock test
  • Add hash load balance stargegy
  • Others


Apache License, Version 2.0

You can’t perform that action at this time.