DEV Community

PGD
PGD

Posted on

RMI (Remote Method Invocation)

RMI (Remote Method Invocation) is an API provided by J2EE platform that defines methods for applications in different systems (JVM in running) to communicate by invocating a method. It defines methods to communicate with different applications in distributed system environment.
RMI provides two objects, each called stub and skeleton. Both stub and skeleton are for building connection. A stub is the object for client-side application and a skeleton is for server-side application.
Once the client invokes a method of stub object, then the stub processes the following tasks.

  • Build a connection to the remote machine (JVM).
  • Route to the server.
  • Convert the parameter data of the remote method to call into a serialized data suitable for transmission (Marshaling).
  • Wait for result from the remote method.
  • Read the result or exception (Unmarshalling).
  • Return the result to the caller.

Once the server receives the signal, then the skeleton process the following tasks.

  • Unmarshall parameters.
  • Invoke the method providing the parameters.
  • Get the return from the method called and marshal it.
  • Send.

Distributed applications should perform the following process:

  • Locating remote method
  • Providing communication with the remote object.
  • Load class definition the method belongs to.

Top comments (0)