Java RMI 和 RPC 有什么区别?
Java RMI 和 RPC 之间的实际区别是什么?
我在一些地方读到 RMI 使用对象?
What is the actual difference between Java RMI and RPC?
I have read in some places that RMI uses Objects?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
RPC是基于C的,因此它具有结构化编程语义,另一方面,RMI是基于Java的技术,并且是面向对象的。
使用 RPC,您可以调用导出到服务器中的远程函数,在 RMI 中,您可以引用远程对象并调用它们的方法,还可以传递和返回更多远程对象引用,这些引用可以分布在许多 JVM 实例中,因此它更强大。
当需要开发比纯客户端-服务器架构更复杂的东西时,RMI 就会脱颖而出。在网络上分布对象非常容易,使所有客户端都可以进行通信,而无需显式建立单独的连接。
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.
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.
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.
RPC 和 RMI 之间的主要区别在于RMI 涉及对象。我们不使用代理函数来远程调用过程,而是使用代理对象。
RMI 具有更大的透明度,即由于将技术集成到语言中,因此利用了对象、引用、继承、多态性和异常。
RMI 也比 RPC 更先进,允许动态调用(接口可以在运行时更改)和对象适应(提供额外的抽象层)。
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.
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 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.
1.方法:
RMI 使用面向对象的范例,用户需要知道对象以及他需要调用的对象的方法。
RPC 不处理对象。相反,它调用已经建立的特定子例程。
2.工作:
使用 RPC,您可以获得看起来非常像本地调用的过程调用。 RPC 处理将调用从本地计算机传递到远程计算机所涉及的复杂性。
RMI 做同样的事情,但是 RMI 传递对对象和正在调用的方法的引用。
RMI = RPC + 面向对象
3.更好的方法:
与 RPC 相比,RMI 是一种更好的方法,尤其是对于较大的程序,因为它提供了更清晰的代码,更容易识别是否出现问题。
4.系统示例:
RPC 系统:
SUN RPC、DCE RPC
RMI 系统:
Java RMI、CORBA、Microsoft DCOM/COM+、SOAP(简单对象访问协议)
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.
RPC doesn't deal with objects. Rather, it calls specific subroutines that are already established.
2. Working:
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.
RMI does the very same thing, but RMI passes a reference to the object and the method that is being called.
RMI = RPC + Object-orientation
3. Better one:
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.
4. System Examples:
RPC Systems:
SUN RPC, DCE RPC
RMI Systems:
Java RMI, CORBA, Microsoft DCOM/COM+, SOAP(Simple Object Access Protocol)
远程过程调用 (RPC) 是一种进程间通信,它允许调用驻留在本地或远程计算机中的另一个进程中的函数。
远程方法调用(RMI)是一个API,它在Java中实现RPC并支持面向对象的范例。
您可以将调用 RPC 视为调用 C 过程。 RPC 支持原始数据类型,而 RMI 支持方法参数/返回类型作为 java 对象。
与 RPC 不同,RMI 易于编程。您可以根据对象而不是原始数据类型序列来思考业务逻辑。
RPC 是语言中立的,与 RMI 不同,RMI 仅限于 java
RMI 比 RPC 慢一点
看一下这篇文章,了解 C 中的 RPC 实现
Remote Procedure Call (RPC) is a inter process communication which allows calling a function in another process residing in local or remote machine.
Remote method invocation (RMI) is an API, which implements RPC in java with support of object oriented paradigms.
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.
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.
RPC is language neutral unlike RMI, which is limited to java
RMI is little bit slower to RPC
Have a look at this article for RPC implementation in C
来自此处。
如需更多信息和示例,请查看此处。
From here.
For more information and examples, have a look here.
RPC 和 RMI 之间唯一真正的区别在于 RMI 涉及对象:我们不是通过代理函数调用函数,而是通过代理调用方法。
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.
RMI 和 RPC 的区别在于:
The difference between RMI and RPC is that:
RPC 是一种基于 C 的旧协议。它可以调用远程过程并使其看起来像本地调用。RPC 处理将远程调用传递给服务器并将结果传递给客户端的复杂性。
Java RMI 也实现了相同的功能,但略有不同。它使用对远程对象的引用。因此,它所做的是发送一个引用到远程对象以及要调用的方法的名称。这样做更好,因为在大型程序的情况下,它可以生成更清晰的代码,并且通过网络分发对象使多个客户端能够调用服务器中的方法,而不是单独建立每个连接。
RPC is 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.
Java RMI also 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.