RMI (intro)
What is RMI?
RMI stands for Remote Method
Invocation. It is an application programming interface (API) that allows an object running on one Java Virtual Machine (JVM) to
invoke methods on an object running on another Java Virtual Machine (JVM), client server architecture
is a good example where RMI is used. Basically, RMI provides for communication
between programs written in the Java programming language.
Architecture
In an RMI application there are
two programs, a server side program and a client side program. Inside the
server side program, a remote object is created and reference of that object is
made available for clients. The client side program requests the remote object
from the server to invoke its methods.
(A diagram to represent RMI architecture)
Stub & Skeleton?
- Stub is a representation the remote object in the client and its acts as a gateway for the client program.
- Skeleton is the object that in the server-side. stub communicates with the skeleton to pass request to the remote object.
RRL?
RRL represent Remote Reference Layer, and it is the layer which deals with the references made by the client to the remote object.
Transport Layer?
This is the layer that connects the client and the server over a network.
The Flow
- Client makes a call to the remote object.
- Client's call received by the stub, which eventually passes this request to the remote reference layer (RRL).
- When the client side RRL receives the request, it passes the request to the RRL on the server side by invoking required methods (invoke() method of the object remoteRef).
- RRL on the server side gets the request from the client side RRL.
- RRL on the server side passes the request to the skeleton (proxy on the server).
- Server side invokes the required object and the specific methods on the server.
- Result is again passed to the client.
Why RMI?
RMI API can be used to,
- Minimize the complexity of the application.
- Preserve type safety.
- Minimize the difference between working with local and remote objects.
I developed a simple application to demonstrate the flow of RMI API 😊, all the source codes are available in a GitHub repository. (read README for instruction)
Comments
Post a Comment