LesenRPC
目錄
1簡介
LesenRPC是一款基於netty和protobuffer的高性能RPC框架。LesenRPC 采用四層架構:傳輸層 協議層 編解碼層 應用層,
傳輸層:基於netty,充分利用netty提供異步的、事件驅動的功能,保證服務端的高並發 高性能.
協議層:基於protobufer,保證多語言無縫調用.
編解碼層:參考spring架構,采用工廠模式和觀察者模式,對開發者既能透明化調用,也可以輕松的擴展,介入系統的任何流程.
應用層:業務代碼,客戶端只需業務接口即可實現透明調用
2 架構

3 使用指南
一 從這里獲取源碼: http://lesen-rpc.googlecode.com/svn/trunk/
二 服務端 1 制定要導出的接口,並將你的接口打包提供給客戶端,如: interface TestServiceItf { void add(int a,int b); } 2 提供一個服務端實現
3 創建RPCService app = new RPCService(1082);
4 導出你的服務app.exportService("test", new TestService());
5 調用RPCService.run()
參見: com.lesen.rpc.example.ServiceTest
package com.lesen.rpc.example; import com.lesen.rpc.common.export.TestService; import com.lesen.rpc.service.RPCService; public class ServiceTest { public static void main(String[] args) throws Exception { RPCService app = new RPCService(1082); app.exportService("test", new TestService()); app.run(); } }
三 客戶端
參見:com.lesen.rpc.example.ClientTest
package com.lesen.rpc.example; import com.lesen.rpc.client.RPCClient; import com.lesen.rpc.common.export.Service; public class ClientTest { public static void main(String[] args) { String serverName = "test"; String rpcUri = "rpc://127.0.0.1:1082"; RPCClient client = new RPCClient(rpcUri); client.connectService(); Service service = client.getRemoteService(serverName, Service.class);
String result = service.test("test")
System.out.println(result);
client.close();
}
}
4 發展方向
1、支持多語言
2、針對移動設備優化客戶端