Java EE中RPC 和 RMI的区别是什么?

匿名网友 匿名网友 发布于: 2015-08-30 00:00:00
阅读 167 收藏 0 点赞 0 评论 0

RMI:

  • The remote objects are accessed by the references
  • Implements object to object implementation among different java objects to implement distributed communication model.
    – RMI passes the objects as parameters to remote methods.
    – RMI invokes the remote methods from the objects

RPC:

  • The process is through methods / functions
  • Proxy server is involved in processing the procedure calls
  • Calls a procedure remotely like invoking the methods
  • The remoteness is not exactly transparent to the client

1.  RPC 支持多种语言,而 RMI(Remote Method Invocation)只支持 Java 写的应用程序。

2. RMI 调用远程对象方法,允许方法返回 Java 对象以及基本数据类型。而 RPC 不支持对象的概念,传送到 RPC 服务的消息由外部数据表示 (External Data Representation, XDR) 语言表示,这种语言抽象了字节序类和数据类型结构之间的差异。只有由 XDR 定义的数据类型才能被传递, RPC 不允许传递对象。可以说 RMI 是面向对象方式的 Java RPC 

3. RMI中,远程接口使每个远程方法都具有方法签名。如果一个方法在服务器上执行,但是没有相匹配的签名被添加到这个远程接口上,那么这个新方法就不能被RMI客户方所调用。在RPC中,当一个请求到达RPC服务器时,这个请求就包含了一个参数集和一个文本值,通常形成“classname.methodname”的形式。这就向RPC服务器表明,被请求的方法在为“classname”的类中,名叫“methodname”。然后RPC服务器就去搜索与之相匹配的类和方法,并把它作为那种方法参数类型的输入。这里的参数类型是与RPC请求中的类型是匹配的。一旦匹配成功,这个方法就被调用了,其结果被编码后返回客户方。

评论列表
文章目录