PreviousTOCNext

Results and Conclusions

When should you use RMI in your applications? Generally, RMI is a valid option when you want to distribute functions as network services and your application environment is all Java based. If your clients life is only a few seconds in existence, then RMI services will have a detrimental impact due to the overhead of locating (lookup) the remote service. RMI is a great way to distribute business layer and data layer functions by putting the remote service(s) inside the firewall and the client (a Servlet in this case) on your Web server. With Servlets, the service only needs to be located once; once it is located, a static reference can be stored in the Java Virtual Machine. Once the static reference has been created, all Servlets can make use of the remote service without incurring the overhead of performing the remote service lookup. In this fashion, the client applications can treat the remote service as if it were a local method invocation. This approach greatly simplifies coding when remote services can be treated by the application developer as simply another method.

What to watch out for resolves mainly around two issues; overhead and serialization. The largest expense with RMI is looking up the remote service. In testing, it can take several seconds (2-5) to locate the remote service. You must be careful when overriding certain Java methods. The "toString" function will obliterate your remote objects. There may be other Java methods which have this problem. Finally, you must consider object serialization. Every object used remotely must be serializable; that is, they either implement the Serializable interface or their parent class must be serializable. Most objects in Java are serializable, but there are some exceptions.

In conclusion, RMI can be used effectively in a Java only environment where the client applications can absorb the initial overhead associated with locating remote services. RMI provides a reliable and robust messaging interface when you want to provide business and data layer functionality as middleware services.

Additional Reading

Cornell, G., Horstmann, C: Core Java, 2nd ed., SunSoft Press - A Prentice Hall Title, 1997

Harold, Elliotte R.,: Java Network Programming, O'Reilly & Associates, 1997

Java RMI at Sun
Java Distributed Systems (RMI)
RMI DocumentationRemote Method Invocation Specification

PreviousTOCNext

Return to Gerber Family Home Page
directNIC Search
Hosted by directNIC.com