问题
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