Thinking of interview question: comparison between Java RMI and RPC,JMS

Source: Internet
Author: User
Tags soap stub

RPC: (Remote Procedure Call)
A platform-neutral approach designed to communicate between applications, ignoring differences between operating systems and languages. Multi-lingual support

RMI: (Remote Method invocation)
The Java version of RPC, the underlying technology of EJB
RMI uses JRMP (Java Remote method Protocol) communication protocol, which is a kind of remote calling method built on TCP/IP protocol.
RMI uses stubs and skeletons to communicate with remote objects.
The stub acts as the client proxy for the remote object and has the same remote interface as the remote object.
The invocation of the remote object is actually done by invoking the client proxy object stub for the object.

5 Steps to create a remote method call:
1) Define an interface that extends the remote interface, and each method in the interface must declare that it will produce a remoteexception exception;
2) Define a class that implements the interface;
3) Use the Rmic program to generate the necessary stubs and frameworks for remote implementations;
(for example, run in the directory where is located: Rmic demo.rmi.EchoServer)
4) Create a client program and server to make RMI calls;
5) Start the rmiregistry and run your own service programs and client programs.

The difference between RMI and RPC is that:
1) How the method is called
For RMI, if a method executes on the server, but no matching signature is added to the remote interface, the new method cannot be called by the RMI client.
In RPC, when a request arrives at the RPC server, the request contains a parameter set and a literal value, usually in the form of "Classname.methodname".
This indicates that the requested method is called "MethodName" in the "ClassName" class.
The RPC server then searches for the class and method that matches it, and takes it as input to that method parameter type.
The parameter type here is matched to the type in the RPC request. Once the match is successful, the method is called, and the result is encoded and returned to the client side.

2) Restrictions on the delivery of information
RMI invokes remote object methods, allowing methods to return Java objects and basic data types.
While RPC does not allow the delivery of objects, the RPC service message is represented by the external data representation (External data representation,xdr) language.

In addition, the one thing that RMI outperforms RPC or SOAP is that errors caused by object or method mismatches during program development can be discovered at compile time without waiting for the run time.

Note: Another article describes the difference between RPC and RMI:
The RMI underlying protocol is the TCP/IP;RPC underlying protocol: UDP.
Two nouns are not comparable because they are not a class of things:
RMI is a Java distributed framework defined by Sun, including some Java interfaces, and RPC is a network protocol.

JMS is a message specification on the Java platform. A generic JMS message is not an XML, but a Java object.

The difference between JMS and RMI is that:
With JMS services, objects are physically asynchronously moved from one JVM on the network to another.
The RMI object is bound to the local JVM, and only the function parameters and return values are transmitted over the network.

Soap vs. JMS:
1) SOAP focuses on remote service invocation, and JMS focuses on information exchange.
2) In most cases soap is a direct interaction between two systems (Consumer <--> Producer), and in most cases JMS is a tripartite system interaction (Consumer <-Broker, Producer).
Of course, JMS can also implement Request-response mode of communication, as long as the consumer or producer one side of the broker.
3) In most cases, WS is synchronous and JMS is asynchronous. Although WS can also be asynchronous, JMS can also be synchronous.

Reference Documentation: (Comparison of Java RMI and RPC,JMS)

Http:// (RMI and RPC)

HTTP://BLOG.CSDN.NET/YANGDELONG/ARTICLE/DETAILS/4557512 (drill down into soap, RPC, and RMI)

Http:// (RMI for Java RPC communication mechanism, including simple examples) (Rpc,rmi,web SERVICES,JMS)

Thinking about the question: comparison between Java RMI and RPC,JMS

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.