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

Service Registry

下载

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 ?

简单轻量级的RPC框架—HRPC_第1张图片