Remote Method Invocation

What is Remove Method Invocation?

Shehara Grabau
2 min readJul 18, 2020

Remove Method Invocation or RMI is a mechanism used by an object residing in one system to call an object running on another address space. It is the Java version of what is generally known as a Remote Procedure Call (RPC). RMI is used to build distributed systems. RMI creates a public remote server object that enables the client and the server to communicate using simple method calls on the server object.

This communication is handled using two intermediate objects : Stub object which is on the client side and Skeleton object which is on the server side.

The stub/skeleton hides the communication details away from the developer.

The role of the Stub object

The stub is the class that implements the remote interface.

The stub object creates a block of information. This block consists of the remote object identifier that is to be used, the method describing operation number to be used and the method parameters called marshaled parameters.

The role of the Skeleton object

The skeleton is the stub’s counterpart on the server-side.

The skeleton object unmarshalls the parameters and invokes the real object’s method which is on the server. The returned value or the exception is then captured by the skeleton and is marshalled. The package along with the marshalled value is sent back to the stub by the skeleton.

The stub will unmarshalls the value and this is the value of the RMI.

Now let’s look at an example of RMI.

Defining the remote interface :

Implementing the remote interface :

The client program :

The server program :

--

--

Shehara Grabau

Inspired by the little things in life, I aspire to be more.