Skip to content
프로젝트

소개

Netty, ZooKeeper, Spring을 기반으로 한 간단한 RPC 프레임워크

웹 및 앱 개발

이 수치를 측정하는 방법

What you can do

  • Simple code and framework
  • Service registry/discovery support by ZooKeeper
  • High availability, load balance and failover
  • Support different load balance strategy

측정된 스타 증가

in 24h
-1
in 7 days
-3
in 15 days
-3
in 1 month
-4

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

NettyRpc

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

Features:

  • Simple code and framework
  • Service registry/discovery support by ZooKeeper
  • High availability, load balance and failover
  • Support different load balance strategy
  • Support asynchronous/synchronous call
  • Support different versions of service
  • Support different serializer/deserializer
  • Dead TCP connection detecting with heartbeat

Design:

design

How to use (netty-rpc-test)

  1. Define an interface:

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

    @NettyRpcService(HelloService.class, version = "1.0")
    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:

    1. Start server with spring config: RpcServerBootstrap
    2. Start server without spring config: RpcServerBootstrap2
  5. Call the service:

    1. Use the client:
       final RpcClient rpcClient = new RpcClient("127.0.0.1:2181");
           
       // Sync call
       HelloService helloService = rpcClient.createService(HelloService.class, "1.0");
       String result = helloService.hello("World");
           
       // Async call
       RpcService client = rpcClient.createAsyncService(HelloService.class, "2.0");
       RPCFuture helloFuture = client.call("hello", "World");
       String result = (String) helloFuture.get(3000, TimeUnit.MILLISECONDS);
    
    1. Use annotation @RpcAutowired:
    public class Baz implements Foo {
        @RpcAutowired(version = "1.0")
        private HelloService helloService1;
           
        @RpcAutowired(version = "2.0")
        private HelloService helloService2;
           
        @Override
        public String say(String s) {
            return helloService1.hello(s);
        }
    }
    

관련 프로젝트 살펴보기

불러오는 중…