我应该使用哪种Java RMI / RPC / IPC技术? [英] Which Java RMI/RPC/IPC technology should I use?

查看:128
本文介绍了我应该使用哪种Java RMI / RPC / IPC技术?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Java应用程序,它包含一个服务器和一个客户端(将来可能有多个客户端),可以在不同的主机上运行。

I'm developing a Java application that consists of a server and a client (possibly multiple clients in future) which may run on different hosts.

用于这两个我目前使用自定义协议,该协议由通过网络套接字发送的JSON消息组成,并且两端都转换回Java Bean对象。然而,应用程序越复杂,我注意到这种方法不符合我的标准而且过于复杂。

For communication between these two I currently use a custom protocol which consists of JSON messages that are sent over network sockets and that are converted back to Java Bean objects on both sides. However the more complex the application gets I notice that this method doesn't meet my standards and is too complex.

我正在寻找一个完善的,可能标准化的替代方案。

I'm looking for a well established, possibly standardized alternative.

我看过远程方法调用(RMI),但读到协议很慢(网络开销很大)。

I've looked at Remote Method Invocation (RMI) but read that the protocol is slow (big network overhead).

我正在寻找的技术应该是轻量级的(协议和库明智的),健壮的,可能支持压缩(如果确实有大的优势!),可能支持加密,良好的文档和完善的(例如Apache项目) )。它应该像使用RMI调用远程对象上的方法一样简单但没有它的缺点。

The technology I'm looking for should be lightweight (protocol and library wise), robust, maybe support compression (big plus if it does!), maybe support encryption, well document and well established (e.g. an Apache project). It should be as easy as calling a method on a remote object with RMI but without its disadvantages.

你能推荐什么?

推荐答案

Avro 是一个Apache项目,专为跨语言RPC(参见 Thrift 的精神前身)。它是相当新的(不到两年),因此它没有像RMI那样完善。不过,你应该给它一个机会;像卡桑德拉这样的大型项目正在转向Avro。 Avro也是Hadoop下的一个子项目,并且一直得到该社区的健康支持。

Avro is an Apache project that is designed for cross-language RPC (see Thrift for its spiritual predecessor). It is fairly new (less than two years old), so it isn't as well-established as RMI, for example. You should still give it a chance, though; large projects like Cassandra are moving to Avro. Avro is also a sub-project under Hadoop and has been receiving healthy support from that community.

它旨在快速支持多种语言,因此您可能需要在编译过程中引入另一个步骤,将 Avro IDL 文件翻译成Java ,虽然不是绝对必要的。其余的是典型的RPC。

It designed to be fast and support multiple languages, so you will probably need to introduce another step during compilation in which you translate an Avro IDL file into Java, although it isn't strictly necessary. The rest is typical RPC.

Avro的一个好处是它的传输层与数据的表示方式无关。例如,它为原始套接字,HTTP甚至本地进程内调用提供了各种收发器(它们的基本通信类)。 HTTPS和SASL收发器可以提供安全性。

One nice thing about Avro is that its transport layers are independent of how data is represented. For example, it comes with various "transceivers" (their base communication class) for raw sockets, HTTP, and even local intra-process calls. HTTPS and SASL transceivers can provide security.

为了表示数据,有各种类型的编码器和解码器,但默认值为 BinaryEncoder 一般就足够了,因为Hadoop,Cassandra等...专注于效率。还有一个 JsonEncoder 万一你觉得有用。

For representing data, there are encoders and decoders of various types, although the default BinaryEncoder generally suffices since Hadoop, Cassandra, etc... focus on efficiency. There is also a JsonEncoder in case you find that useful.

这篇关于我应该使用哪种Java RMI / RPC / IPC技术?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆