0
10kviews
Explain the architecture of Remote Method invocation (RMI) and its packages.

Explain clearly the architecture of Remote Method invocation (RMI) and its packages.

1 Answer
1
434views

Java Remote Method Invocation (RMI)

  • The RMI stands for Remote Method Invocation is an API mechanism.
  • This mechanism allows an object residing in one system (JVM) to access an object running on another JVM.
  • This mechanism generally creates distributed applications in java.
  • The RMI provides remote communication between the java applications using two objects called stub and skeleton.

The Architecture of Remote Method Invocation (RMI)

  • A remote object is an object whose method can be invoked from another JVM.
  • Java RMI application contains two types of programs such as server program and client program.
  • In the server-side program, a remote object is created, and a reference of that remote object is made available for the client-side using registry.
  • The client-side program requests the remote objects on the server and tries to invoke its methods.

Java RMI Architecture

Components of RMI Architecture

Stub

  • The stub is an object, acts as a gateway for the client-side.
  • All the outgoing requests are routed through it.
  • It resides at the client-side and represents the remote object.
  • When the caller invokes a method on the stub object, it does the following tasks:
  • It initiates a connection with remote Virtual Machine (JVM),
  • It writes and transmits (marshals) the parameters to the remote Virtual Machine (JVM),
  • It waits for the result
  • It reads (unmarshals) the return value or exception, and
  • It finally, returns the value to the caller.

Skeleton

  • The skeleton is an object, acts as a gateway for the server-side object.
  • All the incoming requests are routed through it. When the skeleton receives the incoming request, it does the following tasks:
  • It reads the parameter for the remote method
  • It invokes the method on the actual remote object, and
  • It writes and transmits (marshals) the result to the caller.

Transport Layer

  • This layer connects the client and the server.
  • It manages the existing connection and also sets up new connections.
  • It is responsible for the transportation of data from one machine to another.
  • The default connection is set up only in the TCP/IP protocol.

RRL(Remote Reference Layer)

  • It is the layer that manages the references made by the client to the remote object.
  • This layer gets a stream-oriented connection from the transport layer.
  • It is responsible for dealing with the semantics of remote invocations.
  • It is also responsible for handling duplicated objects and for performing implementation-specific tasks with remote objects.

Working of RMI

  • When the client makes a call to the remote object, it is received by the stub which eventually passes this request to the RRL.
  • When the client-side RRL receives the request, it invokes a method called invoke() of the object remoteRef. It passes the request to the RRL on the server-side.
  • The RRL on the server-side passes the request to the Skeleton (proxy on the server) which finally invokes the required object on the server.
  • The result is passed all the way back to the client.

Packages used in RMI

  • java.rmi - Provides the RMI package.
  • java.rmi.activation - Provides support for RMI Object Activation.
  • java.rmi.dgc - Provides classes and interface for RMI distributed garbage-collection (DGC).
  • java.rmi.registry - Provides a class and two interfaces for the RMI registry.
  • java.rmi.server - Provides classes and interfaces for supporting the server side of RMI.
  • javax.activity - Contains Activity service-related exceptions thrown by the ORB machinery during unmarshalling.
  • javax.management.remote.rmi - The RMI connector is a connector for the JMX Remote API that uses RMI to transmit client requests to a remote MBean server.
  • javax.rmi - Contains user APIs for RMI-IIOP.
  • javax.rmi.CORBA - Contains portability APIs for RMI-IIOP.
  • javax.transaction - Contains three exceptions thrown by the ORB machinery during unmarshalling.
  • org.omg.stub.java.rmi - Contains RMI-IIOP Stubs for the Remote types that occur in java.rmi package.
Please log in to add an answer.