Protocol Buffers Java RPC Stack

2019-04-07 02:15发布

问题:

According to this Wikipedia entry:

"Protocol Buffers is very similar to Facebook’s Thrift protocol, except it does not include a concrete RPC stack to use for defined services. Since Protocol Buffers was open sourced, a number of RPC stacks have emerged to fill this gap."

However, there are no examples of RPC stacks cited. Can anyone suggest a Java-based implementation of an RPC stack?

回答1:

If you want Java-based RPC stack, it's RMI. However, it doesn't work well cross platform.

I've been using ProtoBuf to do RPC. You can pretty much simulate an RPC stack by wrapping a protobuf message inside another protobuf, which defines the services or calls. Find my answer to this question for details,

Google Protocol Buffers and HTTP

Thrift looks like a very good alternative if you want support more platforms like PHP, Ruby, C# etc. However, it looks very complex to me compared to ProtoBuf.



回答2:

Google has open sourced their RPC framework gRPC, which uses Protocol Buffers to define the service and messages. gRPC is cross-platform with support for C, C++, C#, Java, Go, Node.js, Python, Ruby, Objective-C and PHP.

gRPC is based on the HTTP/2 standard that enables new capabilities such as bidirectional streaming, flow control, header compression and multiplexed connections.