Remote Method Invocation
Remote Method Invocation
Java RMI
• Allows a method to be invoked that resides on
a different JVM:
– remote machine
– same machine, different JVM (different
address space)
• Object-oriented RPC
• Java RMI is a mechanism to allow the
invocation of methods that reside on different
• Java Virtual Machines (JVMs). The JVMs may
be on different machines or they could be on
the same machine. In either case, the method
runs in a different address space than the
calling process.
RMI ARCHITECTURE
DISTRIBUTED OBJECT
STUB & SKELETON
• Stubs and Skeletons. Stub is the local code
that serves as a
• proxy for a remote object. The skeleton is
another proxy that
• lives on the same host as the real object. The
skeleton
• receives remote method invocations from the
stub and passes
• them on to the object.
CORBA Vs RMI
• CORBA is language/machine independent
• - RMI was designed for Java running on a JVM
• CORBA includes more mechanisms:
server application starting
managing persistent state
support for transactions
• -Java RMI does not have an Object Broker
Participating processes
• Client
– process that is invoking a method on a remote object
• Server
– process that owns the remote object (local object to
the server)
• Object Registry
– name server that associates objects with names
– objects are registered
– URL namespace
Three entities involved in running a
program that uses RMI:
• client: this is the program that you write to access remote
methods
• server: this is the program that you write to implement
the remote methods – clients connect to the server and
request that a method be executed. The remote methods
to the client are local methods to the server.
• Object registry: this is a program that you use.
The object registry runs on a known port (1099 by default)
A server, upon starting, registers its objects with a textual
name with the object registry.
A client, before performing invoking a remote method,
must first contact the
object registry to obtain access to the remote object.
Two kinds of classes
• Remote class (remote object)
– instances can be used remotely
– works like any other object locally
– in other address spaces, object is referenced