Logo F2FInterview

RMI Interview Questions

Q   |   QA

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.

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.

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 ("//myhost:3271/ HelloRMIRegistry ", 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://myhost/~username/codebase/
                examples.ExampleRMIURL

where ExampleRMIURL is the name of the application. 

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.

The methods of remote objects are to be invoked by implementing the java.rmi.Remote interface.

Methods:

bind(): binds the specified name to the remote object. The name parameter of this method should be in an URL format.

unbind(): Destroys the binding for a specific name of a remote method in the registry

rebind(): Binds again the specified name to the remote object. The current binding will be replaced by rebinding.

list(): Returns the names of the names that were bound to the registry in an array form. These names are in the form of URL-formatted string.

lookup(): A stub, a reference will be returned for the remote object which is related with a specified name.

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: