Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which Java RMI/RPC/IPC technology should I use?

Tags:

java

rpc

ipc

rmi

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.

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.

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

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.

What can you recommend?

like image 589
Sven Jacobs Avatar asked Dec 18 '10 19:12

Sven Jacobs


Video Answer


1 Answers

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.

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.

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.

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.

like image 129
ide Avatar answered Oct 04 '22 17:10

ide