An open API service indexing awesome lists of open source software.

https://github.com/wosyingjun/HRPC

A light-weight high performance RPC framework base on Netty and Zookeeper
https://github.com/wosyingjun/HRPC

Last synced: about 1 month ago
JSON representation

A light-weight high performance RPC framework base on Netty and Zookeeper

Awesome Lists containing this project

README

          

##HRPC
>HRPC is a light-weight high performance RPC framework base on Netty and Zookeeper.

##Features
* Serialize by protostuff
* High performance, load balance and failover
* Service registration and subscription base on zookeeper
* Support asynchronous or synchronous invoking
* Keep-Alived connection, reconnect to server automatically
* Dynamic proxy by cglib
* Write less do more
* Spring support

##HRPC Structure
![](http://i.imgur.com/gnoKl5b.png)

##Service Registry
![](http://i.imgur.com/ckd00L8.png)

##Server Tutorial

#####1. Spring configuration











#####2. Service interfacne
public interface UserService {
public User getUser(String phone);
public User updateUser(User user);
}

#####3. Provide rpc service
@HRPCService(UserService.class)
public class UserServiceImpl implements UserService {

@Override
public User getUser(String phone) {
User user =new User(111,"yingjun",phone);
return user;
}

@Override
public User updateUser(User user) {
user.setName("yingjun@update");
return user;
}
}

##Client Tutorial
#####1. Spring configuration










com.yingjun.rpc.service.OrderService
com.yingjun.rpc.service.UserService
com.yingjun.rpc.service.GoodsService




#####2. Synchronous invoking
UserService userService = rpcClient.createProxy(UserService.class);
User user1 = userService.getUser("188888888");
logger.info("result:" + user1.toString());

#####3. Asynchronous invoking
AsyncRPCProxy asyncProxy = rpcClient.createAsyncProxy(UserService.class);
asyncProxy.call("getUser", new AsyncRPCCallback() {
@Override
public void success(Object result) {
logger.info("result:" + result.toString());
}

@Override
public void fail(Exception e) {
logger.error("result:" + e.getMessage());
}
}, "188888888");

##Why choose protostuff ?
![](http://s5.51cto.com/wyfs02/M01/81/13/wKioL1dFyJfgnbJ1AABqzuFWzhw689.jpg-s_1893809398.jpg)