Comparison of Java RMI with RPC, JMS

RPC: (Remote Procedure Call) 
  is designed to be a platform-neutral way of communicating between applications, regardless of differences between operating systems and languages. Supports multiple languages

RMI: (Remote Method Invocation) 
The Java version of RPC, the basic technology of EJB, 
RMI adopts the JRMP (Java Remote Method Protocol) communication protocol, which is a remote invocation method built on the TCP/IP protocol. 
RMI uses stubs and skeletons to communicate with remote objects. 
  The stub acts as a client proxy for the remote object and has the same remote interface as the remote object. 
  The call of the remote object is actually done by calling the client proxy object stub of 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 generate a RemoteException exception;
2) Define a class that implements the interface;
3) Use rmic The program generates the stubs and skeletons required for the remote implementation;
  (for example, run in the directory where demo.rmi.EchoServer.java is located: rmic demo.rmi.EchoServer)
4) Create a client program and server to make RMI calls;
5) Start rmiregistry and Run your own server and client programs.

The difference between RMI and RPC is: 
1) How methods are called
  For RMI, if a method is executed on the server, but no matching signature is added to the remote interface, then the new method cannot be called by RMI Called by the client. 
  Whereas in RPC, when a request arrives at the RPC server, the request contains a parameter set and a text value, usually of the form "classname.methodname". 
  This indicates that the requested method is in the "classname" class, named "methodname". 
  The RPC server then searches for a matching class and method and uses it as input for that method parameter type. 
  The parameter type here matches 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 passing information
  RMI calls remote object methods, allowing methods to return Java objects and basic data types. 
  While RPC does not allow objects to be passed, the messages of RPC services are represented by the External Data Representation (XDR) language.

In addition, one of the advantages of RMI over RPC or SOAP is that errors caused by object or method mismatches during program development can be found at compile time, rather than at runtime.

#############################
Note: Another article describes the difference between RPC and RMI as:
  RMI underlying protocol is TCP/IP; RPC The underlying protocol is: UDP.
  The two terms are not comparable, because they are not a class of things:
    RMI is a Java distributed framework defined by Sun , including some Java interfaces, etc.; and RPC is a network protocol .
http://kylinsoong.iteye.com/blog/801072 
#############################

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

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

Comparison between SOAP and JMS: 
1) SOAP focuses on remote service calls, while JMS focuses on information exchange.
2) In most cases soap is a direct interaction between two systems (Consumer <--> Producer), while in most cases JMS is a three-party system interaction (Consumer <- Broker -> Producer). 
  Of course, JMS can also implement communication in the request-response mode, as long as either the Consumer or the Producer is the broker.
3) In most cases, WS is synchronous and JMS is asynchronous. Although, WS can also be asynchronous and JMS can also be synchronous.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326483283&siteId=291194637