RMI is a Java network programming API which use the JRMP protocol. If we analyze packets with Wireshark, it shows that the JRMP protocol requires at least 2 request exchanges before establishing a communication between a client and a server.
More detail: The first request exchange is the negotiation step, the second request exchange is the lookup()
step, then the other request exchanges are the remote procedure calls (when we use methods from our class which extends Remote
). The first remote procedure call contains serialized class's attribute names, if the same method is called a second time there will be some optimisations (an integer
id will be used for each attribute name instead of String
).
Less detail: JRMP is complex, because it requires multiple client/server request exchanges. A protocol like HTTP only requires one.
Consider we are working on the cloud, we have multiple nodes with RMI servers, we also have a round-robin load balancer between the RMI clients and our cloud. RMI client sends a negotiation request and the first node receives it, then the load balancer send the lookup()
request to the second node... Is it possible to use RMI in a distributed environment?