Search code examples
javarmi

Does all network traffic go through the RMI registry?


This may seem like a simple question, but I can't find the definite answer:

Say I have three servers on a local un-firewalled network, one of which is the registry (R) and the other two are clients (A and B), and Client A and B both connect to the registry.

Client A obtains a reference to an exported object on B via the registry and invokes a method - does that method call go through the registry? i.e. if A passes a large byte array to B as a parameter to a method call, does that take 2 hops via R, or does the registry tell A that B can be communicated with directly?


Solution

  • No, calls from client to server to not pass through the RMI registry. The registry is only used to look up the reference to the server. Subsequent calls to the server go there directly.

    The RMI registry is really nothing more than an RMI server itself, which accepts and stores remote stubs for servers which register with it. It provides a known point-of-entry for clients who don't know where to find the server. It hands the RMI stub back to the client, and the client then talks direct to the server via that stub.