Java RMI 和 RPC 有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2728495/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 12:11:35  来源:igfitidea点击:

What is the difference between Java RMI and RPC?

javarmirpc

提问by Aran

What is the actual difference between Java RMI and RPC?

Java RMI 和 RPC 之间的实际区别是什么?

I have read in some places that RMI uses Objects?

我在某些地方读到 RMI 使用对象?

采纳答案by fortran

RPC is C based, and as such it has structured programming semantics, on the other side, RMI is a Java based technology and it's object oriented.

RPC 是基于 C 的,因此它具有结构化的编程语义,另一方面,RMI 是一种基于 Java 的技术,它是面向对象的。

With RPC you can just call remote functions exported into a server, in RMI you can have references to remote objects and invoke their methods, and also pass and return more remote object references that can be distributed among many JVM instances, so it's much more powerful.

使用 RPC,您可以调用导出到服务器的远程函数,在 RMI 中,您可以引用远程对象并调用它们的方法,还可以传递和返回更多远程对象引用,这些引用可以分布在许多 JVM 实例中,因此它更强大.

RMI stands out when the need to develop something more complex than a pure client-server architecture arises. It's very easy to spread out objects over a network enabling all the clients to communicate without having to stablish individual connections explicitly.

当需要开发比纯客户端-服务器架构更复杂的东西时,RMI 会脱颖而出。在网络上散布对象非常容易,使所有客户端无需明确建立单独的连接即可进行通信。

回答by Kyle Rozendo

RMI or Remote Method Invokation is very similar to RPC or Remote Procedure call in that the client both send proxy objects (or stubs) to the server however the subtle difference is that client side RPC invokes FUNCTIONSthrough the proxy function and RMI invokes METHODSthrough the proxy function. RMI is considered slightly superior as it is an object-orientedversion of RPC.

RMI或远程方法Invokation非常类似于RPC或客户端的远程过程调用同时发送的代理对象(或存根)到服务器然而微妙的不同之处在于客户端RPC所调用功能通过代理功能和RMI调用方法通过代理功能。RMI 被认为稍微优越一些,因为它是RPC的面向对象版本。

From here.

这里开始

For more information and examples, have a look here.

有关更多信息和示例,请查看此处

回答by Humphrey Bogart

The main difference between RPC and RMI is that RMI involves objects. Instead of calling procedures remotely by use of a proxy function, we instead use a proxy object.

RPC 和 RMI 之间的主要区别在于RMI 涉及对象。我们不是使用代理函数远程调用过程,而是使用代理对象

There is greater transparency with RMI, namely due the exploitation of objects, references, inheritance, polymorphism, and exceptions as the technology is integrated into the language.

RMI 具有更高的透明度,即由于将技术集成到语言中时对对象、引用、继承、多态性和异常的利用。

RMI is also more advanced than RPC, allowing for dynamic invocation, where interfaces can change at runtime, and object adaption, which provides an additional layer of abstraction.

RMI 也比 RPC 更先进,允许动态调用(其中接口可以在运行时更改)和对象适应(提供额外的抽象层)。

回答by jiby

The only real difference between RPC and RMI is that there is objects involved in RMI: instead of invoking functions through a proxy function, we invoke methods through a proxy.

RPC 和 RMI 之间唯一真正的区别在于 RMI 中涉及对象:我们不是通过代理函数调用函数,而是通过代理调用方法。

回答by sis

The difference between RMI and RPC is that:

RMI 和 RPC 的区别在于:

  • RMIas the name indicates Remote Method Invoking: it invokes a method or an object. And
  • RPCit invokes a function.
  • RMI作为名称表示远程方法调用:它调用一个方法或一个对象。和
  • RPC它调用一个函数。

回答by Dhaval Simaria

1. Approach:

一、方法:

RMI uses an object-oriented paradigm where the user needs to know the object and the method of the object he needs to invoke.

RMI 使用面向对象的范例,其中用户需要知道他需要调用的对象和对象的方法。

RPC doesn't deal with objects. Rather, it calls specific subroutines that are already established.

RPC 不处理对象。相反,它调用已经建立的特定子程序。

2. Working:

2. 工作:

With RPC, you get a procedure call that looks pretty much like a local call. RPC handles the complexities involved with passing the call from local to the remote computer.

使用 RPC,您会得到一个看起来很像本地调用的过程调用。RPC 处理将调用从本地计算机传递到远程计算机所涉及的复杂性。

RMI does the very same thing, but RMI passes a reference to the object and the method that is being called.

RMI 做同样的事情,但 RMI 传递对对象和正在调用的方法的引用。

RMI = RPC + Object-orientation

RMI = RPC + 面向对象

3. Better one:

3.更好的一个:

RMI is a better approach compared to RPC, especially with larger programs as it provides a cleaner code that is easier to identify if something goes wrong.

与 RPC 相比,RMI 是一种更好的方法,尤其是对于较大的程序,因为它提供了更清晰的代码,如果出现问题更容易识别。

4. System Examples:

4. 系统示例:

RPC Systems: SUN RPC, DCE RPC

RPC 系统: SUN RPC、DCE RPC

RMI Systems: Java RMI, CORBA, Microsoft DCOM/COM+, SOAP(Simple Object Access Protocol)

RMI 系统: Java RMI、CORBA、Microsoft DCOM/COM+、SOAP(简单对象访问协议)

回答by Ravindra babu

Remote Procedure Call (RPC)is a inter process communication which allows calling a function in another process residing in local or remote machine.

远程过程调用 (RPC)是一种进程间通信,它允许调用驻留在本地或远程机器上的另一个进程中的函数。

Remote method invocation (RMI)is an API, which implements RPC in java with support of object oriented paradigms.

远程方法调用 (RMI)是一种 API,它在 Java 中实现了 RPC,并支持面向对象的范例。

  1. You can think of invoking RPC is like calling a C procedure. RPC supports primitive data types where as RMI support method parameters/return types as java objects.

  2. RMI is easy to program unlike RPC. You can think your business logic in terms of objects instead of a sequence of primitive data types.

  3. RPC is language neutral unlike RMI, which is limited to java

  4. RMI is little bit slower to RPC

  1. 您可以认为调用 RPC 就像调用 C 过程。RPC 支持原始数据类型,而 RMI 支持方法参数/返回类型作为 java 对象。

  2. 与 RPC 不同,RMI 易于编程。您可以根据对象而不是原始数据类型序列来考虑您的业务逻辑。

  3. 与 RMI 不同,RPC 是语言中立的,RMI 仅限于 Java

  4. RMI 比 RPC 慢一点

Have a look at this articlefor RPC implementation in C

看一下这篇文章,了解 C 中的 RPC 实现

回答by Ruben Bhattacharya

RPCis an old protocol based on C.It can invoke a remote procedure and make it look like a local call.RPC handles the complexities of passing that remote invocation to the server and getting the result to client.

RPC是基于 C 的旧协议。它可以调用远程过程并使其看起来像本地调用。RPC 处理将远程调用传递给服务器并将结果传递给客户端的复杂性。

Java RMIalso achieves the same thing but slightly differently.It uses references to remote objects.So, what it does is that it sends a reference to the remote object alongwith the name of the method to invoke.It is better because it results in cleaner code in case of large programs and also distribution of objects over the network enables multiple clients to invoke methods in the server instead of establishing each connection individually.

Java RMI也实现了同样的事情,但略有不同。它使用对远程对象的引用。因此,它所做的是发送对远程对象的引用以及要调用的方法的名称。它更好,因为它导致更清晰在大型程序的情况下以及通过网络分发对象的代码使多个客户端能够调用服务器中的方法,而不是单独建立每个连接。