Options for remote communication (differences between RPC, WebService, RMI, and JMS)

Source: Internet
Author: User
Tags wsdl

RPC (Remote Procedure Call Protocol)

RPC uses the C/S mode and HTTP protocol to send requests to the server, waiting for the server to return results. This request includes a parameter set and a text set, usually in the form of "classname. methodname. The advantage is that cross-language cross-platform, C-and S-ends have greater independence. The disadvantage is that they do not support objects and cannot check errors in the compiler. They can only be checked at runtime.

 

Web Service

The Web Service provides services based on WEB containers. The underlying layer uses the HTTP protocol, similar to a remote service provider, such as the weather forecast service, which provides weather forecasts for clients in various regions, it is a request response mechanism that is cross-system and cross-platform. A servlet is used to provide services.

 

First, the client's WSDL from the server to the WebService, and the client claims that a proxy class is responsible

The server requests and response. When a data (in XML format) is encapsulated into a data stream in soap format and sent to the server, A process object is generated, and the soap packet that receives the request is parsed. Then, the transaction is processed, and the calculation result is then soap

Package, and then use this package as a proxy class that response sends to the client. Similarly, this proxy class parses the soap package and then performs subsequent operations. This is a running process of WebService.

 

Web services are divided into five levels:

1. Http Transmission Channel

2. XML data format

3. Soap Encapsulation Format

4. Description of WSDL

5. UDDI is a directory service that enterprises can use to register and search WebServices.

 

RMI (Remote Method Invocation)

RMI uses stubs and skeletons for remote object communication. Stub acts as the client proxy for the remote object and has the same remote interface as the remote object. The call to the remote object is actually done by calling the client proxy object stub of the object, through this mechanism, RMI is like working locally. Using the TCP/IP protocol, the client directly calls some methods on the server. The advantage is the strong type, which can be checked during compilation. The disadvantage is that it can only be based on the Java language, and the client and server are tightly coupled.

 

JMS (Java Messaging Service)

JMS is a Java Message Service. JMS clients can transmit messages asynchronously through the JMS service. JMS supports two message models: point-to-point (P2P) and publish/subscribe (pub/Sub), that is, point-to-point and publish subscription models.

 

Differences and connections between users

 

1. RPC and RMI

 

(1) RPC is cross-language, while RMI only supports Java.

(2) RMI calls remote object methods and allows methods to return Java objects and basic data types. RPC does not support object concepts, messages sent to the RPC service are represented by external data representation (external data representation, XDR), which abstracts the differences between the byte order class and the data type structure. Only data types defined by XDR can be passed. Rmi is an Object-Oriented Java RPC.

(3) In method calling, in RMI, the remote interface enables each remote method to have a method signature. If a method is executed on the server but no matching signature is added to this 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 text value, usually in the form of "classname. methodname. This indicates to the RPC server that the requested method is named "methodname" in the class "classname ". Then the RPC server searches for the matched classes and methods and uses them as the input of the method parameter type. The parameter type here matches the type in the RPC request. Once the matching is successful, this method is called and the result is encoded and returned to the customer.

2. JMS and RMI

 

Using the JMS service, the object is physically asynchronously moved from a network JVM to another JVM (Message notification mechanism)

The RMI object is bound to the local JVM, and only function parameters and return values are transmitted over the network (Request Response Mechanism ).

 

RMI is usually synchronous, that is, when the client calls a server method, it needs to wait until the other party returns to continue executing the client, this process calls local methods in the same way, which is also a feature of RMI.

Generally, JMS sends a message to the Message Server at a single point. After the message is sent, it generally does not concern who uses the message.

Therefore, generally, RMI applications are tightly coupled, while JMS applications are relatively loosely coupled.

 

3. WebService and RMI

 

RMI is a Java object that can be serialized over TCP. It can only be used on java virtual machines. The binding language, client and server must be Java

WebService does not have this restriction. WebService transmits XML text files over HTTP and has nothing to do with the language and platform.

 

4. WebService and JMS

 

WebService focuses on remote service calls, while JMS focuses on information exchange.

 

In most cases, WebService 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 request-response mode communication, as long as one of the consumer and producer serves as the broker.

 

The asynchronous call of JMS can completely isolate the client and service provider, which can withstand traffic peaks. the WebService is usually called synchronously and requires complicated object conversion. Compared with soap, the current JSON, rest is a good HTTP architecture solution. (for example, in E-Commerce distributed systems, there are payment systems and business systems. The payment system is responsible for user payment, after a user makes a payment in a bank, he needs to notify various business systems. At this time, both synchronous and asynchronous can be used. The advantages of asynchronous can be used to withstand the temporary traffic peaks of the website, or it can cope with slow consumers .)

 

JMS is a message specification on the Java platform. Generally, a JMS message is not an XML message, but a Java object. Obviously, JMS does not consider heterogeneous systems. To put it bluntly, JMS does not consider non-Java items. However, most JMS providers (various implementation products of JMS) solve the heterogeneous problem. Compared with cross-platform WebService.

 

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: info-contact@alibabacloud.com 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.