目前RSF存在的問題: java
2.不支持多語言客戶端。這個是體力活,若是去支持的話RSF是能夠作到的。由於RSF傳輸協議是自有的傳輸協議,多語言要解決的只有序列化的問題。 git
例子: bootstrap
Server端: 服務器
RsfBootstrap bootstrap = new RsfBootstrap(); bootstrap.doBinder(new RsfStart() { public void onBind(RsfBinder rsfBinder) throws Throwable { rsfBinder.rsfService(EchoService.class, new EchoServiceImpl()).register(); } }).socketBind(8001); RsfContext rsfContext = bootstrap.sync();
客戶端: app
//1.使用 RSF 引導程序建立 RSF。 RsfBootstrap bootstrap = new RsfBootstrap(); bootstrap.doBinder(new RsfStart() { public void onBind(RsfBinder rsfBinder) throws Throwable { String hostAddress = InetAddress.getLocalHost().getHostAddress(); rsfBinder.bindAddress(hostAddress, 8001);//分佈式的遠程服務提供者:1 rsfBinder.bindAddress(hostAddress, 8002);//分佈式的遠程服務提供者:2 rsfBinder.rsfService(EchoService.class).register(); } }); RsfContext rsfContext = bootstrap.sync(); // //2.獲取遠程服務的包裝類 EchoService myService = rsfContext.getRsfClient().wrapper("RSF", EchoService.class.getName(), "1.0.0", EchoService.class); //3.發起調用 for (int i = 0; i < 1000000; i++) { String echoMsg = myService.echo("你好.."); }
接口和實現類: 框架
public interface EchoService { public String echo(String sayMessage); } public class EchoServiceImpl implements EchoService { public String echo(String sayMessage) { return "RE : " + sayMessage; } }
源碼位置:
http://git.oschina.net/zycgit/rsf 異步