NettyRpc

A simple RPC framework based on Netty, ZooKeeper and Spring

Github星跟蹤圖

NettyRpc

An RPC framework based on Netty, ZooKeeper and Spring
中文详情:Chinese Details

Features:

  • Simple code and framework
  • Non-blocking asynchronous call and Synchronous call support
  • Long lived persistent connection
  • High availability, load balance and failover
  • Service Discovery support by ZooKeeper

Design:

design

How to use

  1. Define an interface:

     public interface HelloService { 
     	String hello(String name); 
     	String hello(Person person);
     }
    
  2. Implement the interface with annotation @RpcService:

     @RpcService(HelloService.class)
     public class HelloServiceImpl implements HelloService {
     	public HelloServiceImpl(){}
    
     	@Override
     	public String hello(String name) {
     		return "Hello! " + name;
     	}
    
     	@Override
     	public String hello(Person person) {
     		return "Hello! " + person.getFirstName() + " " + person.getLastName();
     	}
     }
    
  3. Run zookeeper

    For example: zookeeper is running on 127.0.0.1:2181

  4. Start server:

    Start server with spring: RpcBootstrap

    Start server without spring: RpcBootstrapWithoutSpring

  5. Use the client:

     ServiceDiscovery serviceDiscovery = new ServiceDiscovery("127.0.0.1:2181");
     final RpcClient rpcClient = new RpcClient(serviceDiscovery);
     // Sync call
     HelloService helloService = rpcClient.create(HelloService.class);
     String result = helloService.hello("World");
     // Async call
     IAsyncObjectProxy client = rpcClient.createAsync(HelloService.class);
     RPCFuture helloFuture = client.call("hello", "World");
     String result = (String) helloFuture.get(3000, TimeUnit.MILLISECONDS);

主要指標

概覽
名稱與所有者luxiaoxun/NettyRpc
主編程語言Java
編程語言Java (語言數: 1)
平台
許可證
所有者活动
創建於2016-03-13 05:24:45
推送於2024-10-18 22:19:56
最后一次提交2024-02-04 09:58:36
發布數3
最新版本名稱NettyRpc-1.2 (發布於 2020-09-09 11:24:11)
第一版名稱NettyRpc-1.0 (發布於 )
用户参与
星數2.4k
關注者數157
派生數1.2k
提交數108
已啟用問題?
問題數31
打開的問題數6
拉請求數15
打開的拉請求數1
關閉的拉請求數9
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?