目前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 异步