Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

RMI Interview Questions and Answers

Ques 11. Discuss in brief about Remote Method Invocation (RMI) and its working.

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 X):

* 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 Y) 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.

Is it helpful? Add Comment View Comments
 

Ques 12. What is the difference between RMI and JMS?


RMI

* RMI is tightly-coupled mechanism.
* The destination object need to be available online at the time of sending messages from client to server.
* RMI has RPC-model

JMS

* JMS provides loosely coupled mechanism.
* The destination object need not be available online at the time of sending messages from client to server.
* JMS has messaging model.

Is it helpful? Add Comment View Comments
 

Ques 13. What is Registry Service for RMI?

The registration of the remote object must be done by the server in order for the client to look it up, is called the RMI Registry. In RMI, the client must contact an RMI registry, so that the server side application will be able to contact the client’s registry which points the client in the direction of the service. The client registers the service with the registry so that it is transparent to even for the server.

Is it helpful? Add Comment View Comments
 

Ques 14. Explain how URL convention is used for accessing the registry.

The class rebind () method of java.rmi.Naming class is used to specify the port number . For example if the registry is running on a port number 3271 of an application named HelloRMIRegistry the following is the usage of the URL to reference the remote object:

Naming.rebind ("//host:1111/RMIRegistry", obj);

The URL stored on the web page needs to specify the non-default port number.
When the server’s remote objects created by the server can include the URL from which the stub class can dynamically be downloaded to the client. The following example depicts this:

java -Djava.rmi.server.codebase=http://host/username/codebase/examples.ExampleRMIURL

Is it helpful? Add Comment View Comments
 

Ques 15. Explain how to bind an object to the registry.

If an object implements the java.rmi.Remote interface, an object is to be bound to registry context. Each registry context implements the Referenceable interface.

The object factory is implemented by the RegistryContextFactory which converts the registry references into the corresponding registry contexts or remote objects. To construct the registry constructs, the URL of the registry must be determined. In this way the remote objects will be bounded with registry contexts.

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2024 WithoutBook