# NettyRPC **Repository Path**: zzserver/NettyRPC ## Basic Information - **Project Name**: NettyRPC - **Description**: 基于Netty和zookeeper实现带注册中心的rpc框架 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-09-02 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # NettyRpc An RPC framework based on Netty, ZooKeeper and Spring 中文详情:[Chinese Details](http://www.cnblogs.com/luxiaoxun/p/5272384.html) ### 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 #### 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 { @Override public String hello(String name) { return "Hello! " + name; } @Override public String hello(Person person) { return "Hello! " + person.getFirstName() + " " + person.getLastName(); } } 3. Run zookeeper 4. Start server: RpcBootstrap 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);