- Tech know how online

remote method invocation (RMI)

Remote Method Invocation (RMI) refers to a specific method of the Javaprogramming language for the remote invocation of methods and access variables. This results in the automatic generation of so-called stub and skeleton classes by the runtime environment. For example, a client can call methods on the server like normal Java functions. With RMI a transparent sending of objects - including the relevant functions - as well as a dynamic reloading of object classes is supported. An alternative communication between objects is called Remote Procedure Call( RPC), which can then also be used to call methods or execute procedures in external programs. The application areas of RMI are to be found above all in classical client server architectures.

The starting point for RMI was the realization of a distributed object model in Java, and thereby the interaction of remote objects similar to that of local objects to arrange. Remote objects in this context are those that are either located on remote, external computer systems or run separately on a self-sufficient Java Virtual Machine( JVM). For communication, RMI provides various protocols tailored to the specific purpose. Java Remote Method Protocol( JRMP) - also called Wire Protocol - is the implemented standard protocol. With RMI IIOP, a protocol is available for integration in the Common Object Request Broker Architecture( CORBA) - another mechanism for distributed application programming. With RMI tunneled over HTTP, a way to bypass firewalls is available. And finally, with RMI and encryption via Secure Socket Layer( SSL), a mechanism for secure communication is available.

In the standard Java environment, all the necessary methods and mechanisms are implemented in the RMI class library. Using remote objects in the same way as local objects as well as handling methods in remote objects similarly to local calls are supported by this class library. A more sophisticated mechanism ensures that methods of remote objects can be called to pass objects in whole or in part as a value or referenced address. Additionally implemented mechanisms for handling exceptions such as communication errors in the network, which may well occur during the execution of remote operations, are further components of the class library. The java.rmi package contains the general RMI interfaces as well as the corresponding classes and exceptions.

RMI levels

RMI levels

For this RMI integrates three different levels, which are traversed by the individual method calls depending on the specific application - external or the same system with different JVMs. The figure illustrates the relationships and tasks of these levels.

  • The transport level deals with the network connection between the systems.
  • The compilation of the method call and its parameters as well as the preparation of the return values is the task of the "Remote Reference" level.
  • With the levels "Stubs" on the Client as well as "Skeleton" on the server act on both sides quasi representative objects, which take over the data of the actual implementation class and/or to this the appropriate results return. The Stub object is thus the local representative for the remote object.

An alternative way of communication between objects is called Remote Procedure Call (RPC). With it methods or procedures can be called over a network connection likewise in other programs. Thereby RMI and RPC have some similarities. The difference, however, is that RPC is based on the invocation of procedures, and the corresponding arguments of the other side are provided only in reconstructible form. In contrast, RMI exchanges a complete object, which better reflects the object-oriented principles associated with a distributed object model.

In principle, wide-ranging communication of arbitrarily distributed systems is possible via RMI, but RMI is often used in traditional client-server architectures, where a number of clients maintain connections to a single server that handles their requests.

Englisch: remote method invocation - RMI
Updated at: 11.03.2010
#Words: 619
Links: method, remote, stub, runtime environment (RTE), client
Translations: DE

All rights reserved DATACOM Buchverlag GmbH © 2022