Logo F2FInterview

RMI Interview Questions

Q   |   QA

a. MalFormedURLException
b. NotBoundException
c. RemoteException 

In distributed systems, a client calls a procedure stored on a server. This is called calling a remote procedure stored on a server. Though, the call is made as if the procedure was stored on the local machine.

The steps in which a RPC is made are:

  • The client calls the procedure
  • The client stub builds the message.
  • The message is sent over the network.
  • The Server OS gives the message to the server stub.
  • The server stub unpacks the message.
  • The stub makes a local call to the procedure.
  • The server does the work and returns the result to the server stub.
  • The stub packs the message and traps to the kernel.
  • The remote kernel sends the message the client kernel.
  • The client kernel gives the message to the client stub.
  • The client stub unpacks the result and gives to the client. 

Advantages:

  1. RPC provides interoperability between CORBA ORB implementations.
  2. A lightweight RPC protocol permits efficient implementations.

Disadvantages:

  1. RPC implementations are not yet mature.
  2. It requires the TCP/IP protocol. Other transport protocols are not supported yet.
  3. Not yet proven over wide-area networks.

RMI:

  • The remote objects are accessed by the references
  • Implements object to object implementation among different java objects to implement distributed communication model.
    • RMI passes the objects as parameters to remote methods.
    • RMI invokes the remote methods from the objects

RPC:

  • The process is through methods / functions
  • Proxy server is involved in processing the procedure calls
  • Calls a procedure remotely like invoking the methods
  • The remoteness is not exactly transparent to the client

RMI is a java object equivalent process that invokes a method in a distributed environment.

RMI performs the communication among objects using object-to-object communication. RMI uses the objects distribution techniques and invokes methods of objects which are located in a remote site.

Working of RMI:

The code from machine A is being accessed for the object that is residing on machine B in a remote relocation. There are two intermediate objects called a ‘stub’ and a ‘skeleton’, which actually handles the communication. The following are the tasks that performed by these two objects:

Task that are to be handled by the stub object (on machine A):

  • Building a information block which consists of
    • an identifier of the remote object
    • an operation number that describes the method to be called and
    • the method parameters called marshaled parameters that are to be encoded into a suitable format for transporting over the network
  • Sending the information to the server.

The tasks that are to be handled by the skeleton object (on machine B) are:

  • Unmarshalling the parameters
  • Invoking the required method of the object which is lying on the server
  • Capturing and returning the value if successful or an exception if unsuccessful , after the call on the server
  • Marshalling the returned value
  • Packaging the value that is in the marshaled form and sending to the stub on the client.

Subsequently the stub object unmarshals the return value or exception from the server as the case may be. This is the returned value of the remote method invocation. If an exception is thrown, the stub object will rethrow the exception to the caller. 

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: