RMI is Dead, but Textbooks and Colleges shouldn’t Stop Teaching it

It’s easy to understand distributed system architecture if you are familiar with RMI.

INDRAJITH EKANAYAKE
CARRE4
3 min readJan 28, 2021

--

Photo by Matt Artz on Unsplash

Why do people study history even though it is not going to help in the future? There could be some hidden advantage and same applies here.

RMI stands for Remote Method Invocation and it allows Java developers to write an object to invoke methods on an object running in another JVM. But here JVM1(we call it client) and JVM2(we call it server) do not communicate directly, there are few layers in between.

Source: https://www.tutorialspoint.com/java_rmi/java_rmi_introduction.htm

When a client makes a call to the remote object it is received by the stub(proxy on the client). The stub will pass that message to the Remote Reference Layer(RRL) and when the client-side RRL receives the request it invokes a method called invoke() and it passes the message to the server-side RRL. RRL passes the request to the skeleton(proxy on the server) and it invokes the object on the server. Finally, the result is passed to the client back.

In addition to the common advantages of using a proxy such as a load balancing, privacy and security stub and skeleton both hide some complexity when it comes to RMI. For example in network-level communication, we are communicating data as a byte stream. Here stub is responsible for converting the data or the objects into a byte-stream(marshalling) where the skeleton is responsible for the reverse process of converting the byte-stream back to their original data or object(unmarshalling) and this marshalling and unmarshalling conversion is achieved through a process called “serialization”.

There is a Middleman - RMI Registry

Photo by Holly Stratton on Unsplash

RMI registry is the place which all server objects are placed. Each time the server creates an object, it registers this object with the RMIregistry (using bind() or reBind() methods). These are registered using a unique name known as bind name. The client does not know which object to call but RMI Registry does. So the client contacts the RMI registry and lookup for the reference of that object(using lookup() method).

Java RMI vs Socket Programming

In Socket programming you have to handle exactly which sockets are being used, you specify TCP or UDP, you handle all the formatting of messages travelling between client and server. However, if you have an existing program that talks over sockets that you want to interface to, it doesn’t matter what language it’s written in, as long as message formats match.

RMI hides much of the network-specific code, you don’t have to worry about specific ports used (but you can if you want), RMI handles the formatting of messages between client and server. However, this option is really only for communication between Java programs. (You could interface Java RMI programs with programs written in other languages, but there are probably easier ways to go about it)

Conclusion

RMI and CORBA(Common Object Request Broker Architecture) attempt to solve a problem that people thought was important in the early 1990s. However, today we can’t consider RMI as modern technology and nowadays we have REST, SOAP as the de-facto standards for communicating with remote services. Less security, overhead, Java only environment support caused its quick death and today in 2021 following picture tells us the story without any context.

Source: https://trends.google.com/trends/explore?date=today%205-y&q=rmi,rest,soap

Resources:

https://docs.oracle.com/javase/tutorial/rmi/overview.html

http://www.javacoffeebreak.com/articles/javarmi/javarmi.html

https://www.javatpoint.com/RMI

https://www.tutorialspoint.com/java_rmi/java_rmi_introduction.htm

https://docs.oracle.com/javase/7/docs/technotes/guides/rmi/

--

--

INDRAJITH EKANAYAKE
CARRE4
Writer for

Microsoft MVP | Lecturer | Researcher enjoys simplifying tech. Connect with me on https://www.linkedin.com/in/indrajithek/