Bind multiple remote objects to the same RMI registry

谁说我不能喝 提交于 2019-12-11 08:32:44

问题


I have a client program that calls remote methods on a server. Now, I want to create 3 different servers based upon the IP address sent by the client.

Question: Should I create 3 different Remote objects and bind them to the same registry. or should I create 3 different Remote objects and bind them to their respective registry ??

What I am doing right now is one Remote object and binding all 3 objects to the same registry.

Remote obj=UnicastRemoteObject.exportObject(this,2026);
Registry r=LocateRegistry.createRegistry(2026);
r.bind("NA", obj);
r.bind("EU", obj);
r.bind("AS", obj);


回答1:


It has been a long time since I worked with RMI; be that as it may, my advice is to bind all objects in the same registry, which, I guess, you are already doing.




回答2:


There's no reason to use multiple Registries in the same host, especially if they are all started by the same JVM. Use a single one. Multiple entries in a single hash table inside one Registry are a lot cheaper than multiple Registries.



来源:https://stackoverflow.com/questions/21516906/bind-multiple-remote-objects-to-the-same-rmi-registry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!