Java Remote Method Invocation (RMI), which is an object-oriented version of Remote Procedure Call (RPC), has been included with the Java Development Kit release 1.1. RMI provides a simple and powerful Java-to-Java communication model for invoking member functions on objects that exist in other Java virtual machines, exactly as if it were local objects running in the same virtual machines. An overview of the RMI model is shown in figure 2.1.
The RMI architecture consists of three independent layers between the application program and the Java virtual machine. Each layer is independent and can be replaced by an alternate implementation. The three layers are the Stub and Skeleton Layer, the Remote Reference Layer, and the Transport Layer. When a single request occurs, it travels down through the layers on one computer and up through the layers at the other end.
The stub and skeleton layer is responsible for marshaling and unmarshaling the data and transmitting and receiving them to/from the Remote Reference Layer. The data are marshaled and unmarshaled using a parameter-passing mechanism called object serialization. Object serialization is an essential feature needed by Java's RMI implementation. It provides a program the ability to read or write a whole object to and from a raw byte stream. Object serialization allows Java objects and primitives and to be encoded into a byte stream suitable for streaming to some type of network or to a file-system. In order to provide this functionality, an object must implement the Serializable interface.
The Remote reference layer is responsible for carrying out the invocation. It can be behave differently depending on the parameters passed by the calling program. For example, this layer can determine whether the request is to call a single remote service or multiple remote programs as in a multi-cast.
The Transport layer is responsible for setting up connections, managing requests, monitoring them and listening for incoming calls.
High performance distributed computing can be done with Java RMI, but this has a few drawbacks since RMI is designed for client-server programming in Web based systems over slow networks. In parallel programming fast RMI with low latency and high bandwidth would be required. A better serialization would be needed, since Java's object serialization often takes 25%-50% of the time [#!PHILIPPSEN99!#] needed for a remote invocation.