Slashdot Mirror


Java RMI

Reader amoon writes: "With the rise of XML-based RPC (e.g. SOAP, XML-RPC, APEX), the distributed computing world is starting to really unsettle from the CORBA-RMI-DCOM oligopoly of the 1980s and 1990s. Yet, XML-based RPC is not a panacea (though it is quite cool), especially for those of us involved in the legacy and client-server worlds. Now, what is fascinating: the publishing world is revving up the engines on not only the XML-based RPC stuff, but also the RMI and CORBA stuff -- while rarely applied to the tech industry, the old adage, "what was old is new again," seems to fit well here. This review describes this über-cool trend from the RMI perspective, with a focus on Java RMI (O'Reilly) by William Grosso." Read on for the rest of the review. Java RMI author William Grosso pages 545 publisher O'Reilly rating 8 reviewer amoon ISBN 1-56592-452-5 summary Solid practical insight into the nitty-gritty details of RMI.

The Scoop

Remote Method Invocation (RMI) is the object-oriented remote procedure call (ORPC) facility for distributed programming in Java, since the 1.1 days. RMI also served as motivation and a proof-of-concept for jini, javaspaces, and numerous other solid distributed networking technologies. Of course, anyone from the academic distributed programming world knows Wollrath, Waldo, and Riggs.

Yet, despite a myriad of books over the past five years on network programming, RMI always seemed to be the stepchild: relegated to a single chapter (buried on page 496, of course) that always said that RMI was "better" than sockets and "worse" than CORBA. Now, granted that RMI is operationally rather trivial compared with CORBA and was (prior to RMI/IIOP) a unilanguage distributed ORPC technology -- but still. For those of us who have to interoperate with RMI (whether welcome from the Java world or not), the lack of in-depth technical analysis (beyond the spec) has been a hindrance.

Fortunately, this trend is finally starting to buckle with the release of several in-depth RMI books including: Java RMI, Java.rmi, and Mastering RMI: Developing Enterprise Applications in Java and EJB. As evidence of this problem, Grosso states the same in his introduction – and actually pulls it off without sounding self-serving.

I chose Grosso's text because of the cute squirrel (aka the O'Reilly brand), Grosso's recent series of articles on the hashbelt algorithm, and his unadulterated academic knowledge management and mathematics bent. Fortunately, I was rewarded: this animal returns to O'Reilly's pre-bubble quality. Koodoos to both Grosso and his editors (Knudsen, Loukides, and Eckstein) for getting the train back on the track.

What's to Like

Bottom line is that Grosso simply covers the topics and does so with solid conceptual and code coherence – even by O'Reilly standards (over 40 animals grace my shelves). His prose and explanatory patterns make it clear that he has actually gotten into the real-world of RMI, and doesn't hesitate to highlight both good and bad parts. You cannot be dozing off when you read this (at least not if you expect to understand it) -- this is written by someone with solid analytic thinking skills and it shows. After too many years of "there are no caveats" journalism and publishing, this is a nice reversion. Further, I can only imagine that his current employment is a testament to his real-world knowledge of RMI.

Grosso hits on a vein which is not well-appreciated: when not smoothed over by marketing people, RMI is actually a mostly-capable ORPC technology. Certainly activation and RMI/IIOP really began to make things interesting, from Java2 and EJB respectively. Discussion of reference-counted distributed garbage collection, a feature missing from CORBA and other popular ORPC standards, also contributes a nice bonus (although Grosso's ardent attempt to debunk the "RMI doesn't scale" argument is rather weak, even going so far as to rehash the definition of Threads and threadpools – this complexity mismatch is an ugly giveaway that a well-intentioned editor went astray).

What sets this text apart is the tight focus on nitty-gritty implementation details of RMI itself. After all, these RMI texts are way too late to the game to reteach how to write "baby RMI" code: 5 years after the original spec, you either know how to write RMI or you don't. Grosso simply gives you a solid in-depth analysis of all the obscurities of the RMI runtime, custom sockets, dynamic classloading, activation, MarshalledObjects, and HTTP tunneling. In other words, all the interesting real-world topics whose official documentation is poor and which the various RMI tutorials (written many years ago) ignored.

While canonical, the single banking example followed through the text was well-executed, although authors continue to underestimate the prevalence of readers who consume textbooks non-linearly.

What's Not to Like

RMI/IIOP is shaping up to be a fascinating contributor to the "cleanup the EJB mess" discussion. Dedicating a measly 13 pages (beginning on page 503, no less) to this critical topic seems a bit of an oversight – but maybe that is just my CORBA sentiments speaking. Either way, the mechanics of CORBA are sufficiently intricate in real-world deployments that saying "if you can build an RMI system, you can build a CORBA system" (p. 511) is a bit brazen (or naïve) for my tastebuds. I can only chalk up this oversight to deadline pressure, which is probably a Good Thing, since the book was supposedly in production over almost 2 years.

A minor point: the top-level organization of the book (Part I, II, III) is arbitrary, ignore it -- use the chapter organization instead.

The Summary

Quality: solid practical insight into the nitty-gritty operational implementation details of RMI in the real-world. You simply are not going to find solid O'Reilly-quality coverage of the topics elsewhere.

Relevance: If you are responsible for making RMI actually work in production systems, this might well be the next animal on your shelf – either now or later. If you want a breezy afternoon saunter around RMI, skip this. Instead, google one (of the many) free tutorials online."

You can purchase Java RMI from Fatbrain. Want to see your own review here? Just read the book review guidelines, then use Slashdot's handy submission form.

6 of 106 comments (clear)

  1. Amazon has a great review by LunchLady · · Score: 0, Informative

    Even Amazon's review of this book is better. Thanks a lot Slashdot.

  2. Alternate reading by Anonymous Coward · · Score: 1, Informative

    Also see "java.rmi The Remote Method Invocation Guide" by Pitt and McNiff, published by Addison-Wesley. (In my opinion Addison-Wesley has managed to produce a more consistent set of technical titles than O'Reilly, though to be fair standards seem to be rising again for "the animal books".)

    It covers much of the same material and may be useful reading for those less familiar with RMI as it has a longer lead in to the advanced material.

    --
    Dr David Kennedy
    Senior Software Design Engineer
    Nortel Networks
    Not so much anonymous as just infrequent at posting.

  3. RMI works well! by SkyLeach · · Score: 4, Informative

    I have been a java developer for some time. I had the opportunity to use RMI in java to write a distributed client-server pricing solution for a large telecom company. (I'll keep it quiet; I don't want to be sued).

    The problem: Run pricing routines on very large CDR (Call Detail Record) sets. This involved a very complicated process of aggregating calls into time slots and then pricing them according to very complicated long-distance contracts. Pricing very large amounts of data sometimes took as much as two days to price and discount.

    Solution: The implementation (at least in Java) of the RMI standard is simple. In order to avoid purchasing an expensive CORBA implementation we extended our c++ client program with JNI. The client program then called a local wrapper class that used RMI to spin off the pricing call on the remote RMI server. We had big-iron machines running an in-house RMI application server. The application server really just worked as a multi-threaded container that loaded RMI servers from the disk and registered them, allowing a person to order servers to be loaded and/or dropped from the registry via a console.

    The solution was cheap and worked very well.

    --
    My $0.02 will always be worth more than your â0.02, so :-p
  4. Re:Can't determine client from the server side by Hard_Code · · Score: 3, Informative

    You can hack in your contextual message passing (e.g. for authentication and sessioning).

    Try this:

    Implicit contextual info in 1.2-RMI calls

    http://www-und.ida.liu.se/~ricob684/java/ctxrmi/ do cs/index.html

    --

    It's 10 PM. Do you know if you're un-American?
  5. Re:EJB provides this... by jonabbey · · Score: 3, Informative

    Yes, I looked into that option (and even looked at the JBoss sources to see how they were implementing authentication/sessions over RMI), but EJB was simply too heavy duty for my purposes. The app had to run on people's computers, not on central servers.

    You might look at Ganymede. We implemented a session layer using RMI long before J2EE existed. It's not really that hard to do.

  6. Re:garbage collection by jonabbey · · Score: 3, Informative

    Yes, RMI has distributed garbage collection.

    When one host passes a remote object reference to another, the RMI classes on the receiving host track the remote object reference in a client-side data structure. As long as the user-level client code is referencing the remote object, the client will occasionally 'ping' the server with an RMI message that tells the server that the client is still using/referencing the object.

    If the client drops reference to an object, the client will send a release message to the server, which will decrement a distributed reference count. Alternatively, if the client dies, the server's RMI layer will decide after a certain period that it hasn't heard from the client in too long, and will assume that the client dropped off the network.

    Programmers can implement an unreferenced() method in remote objects that will be called by the RMI layer on the server when the object is no longer referenced by a client. This can be used to intelligently handle cleanup on client death, etc.