其中RPC /通讯框架将最适合这个案子? [英] Which rpc/messaging framework would best fit this case?

查看:193
本文介绍了其中RPC /通讯框架将最适合这个案子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用情况:一种Java进程有一个或两个C ++程序,始终在同一台机器上。双向的,是必需的二进制,非持久性的通信。其中的C ++程序的负责实例的其他进程。

Use case : one Java process with one or two C++ processes, always on the same machine. Bidirectional, binary, non-persistent communication is required. One of the C++ process is responsible for instantiating the other processes.

我给环顾四周,看到的东西像XML / JSON-RPC协议缓冲器,节俭,zeromq等。

I have given a look around, seeing things like XML/JSON-RPC, Protocol Buffers, Thrift, zeromq, etc.

如果可能的话,便携性将是不错,但Windows XP / 7是必需的。

If possible, portability would be nice, but Windows XP/7 is required.

推荐答案

在一般来说,你应该在你的设计单独的消息传输和消息德/序列化,并保持它们作为正交越好。总之,去耦数据(消息)从流您的邮件内容的行为。

In general you should separate message transport and message de-/serialization in your design, and keep them as orthogonal as possible. In short, decouple the data (message) flow behavior from your message content.


  1. 有几间面向消息的传输框架,允许为客户机/服务器通信的某些行为模式发送和接收中性有效载荷数据(消息)(请求/应答,发布/订阅,推/拉,...)线程,进程和网络服务的客户端和服务器实例。

  2. 有提供你的有效载荷德/序列化的一些框架(消息)数据中性(例如提供交换独立的机器字节序的整型数据线格式)的方式传输。

  3. 什么是您的特定用例的最佳组合选择,取决于一系列的要求和限制您为您的设计决策:

  1. There are several message oriented transport frameworks, that allow to send and receive neutral payload data (messages) for certain behavioral patterns of client/server communication (request/reply, publish/subscribe, push/pull, ...) between threads, processes and network services as client and server instances.
  2. There are a number frameworks that provide de-/serialization of your payload (message) data in a transport neutral (e.g. providing a wire format for exchanging native integer data independent of machine endianess) manner.
  3. What's the best combination choice for your particular use case, depends on a number of requirements and constraints you have for your design decisions:


  • 可扩展性上的客户端/服务器处理单元的线程,进程或服务器/进程

  • 的整体性能和消息延迟

  • 处理单元的资源需求(例如堆内存或code尺寸)

  • 网络资源的影响(什么是通过网络接口发送)

  • 等。 ...

可能的解决方案:结果
我觉得 ZMQ消息框架与的谷歌的Protobuf 消息framwework可以提供您的使用情况的可行方案。有语言绑定 C ++和 的Java (见的ZMQ Java绑定),你就会有有跨进程,线程间通信的优化实现。 ZMQ连接被设计成类似的方式的插座,该支持双向(请求/应答)的通信模式,以及单向(发布/订阅,推/拉)。

Possible Solution:
I think the ZMQ messaging framework in combination with the Google Protobuf message framwework could offer a viable solution for your use case. There are language bindings for c++ and java (see ZMQ Java binding) and you'll have have the optimized implementations for inter-process and inter-thread communications. ZMQ connections are designed in a socket like manner, that support bi-directional (request/reply) communication patterns as well as uni-directional (publish/subscribe, push/pull).

如前所述,消息内容的格式是由你,但谷歌的Protobuf 可能是适当的内部定义的消息协议,这都支持C ++和Java语言绑定。 谷歌的Protobuf还提供了一种机制来定义的 RPC服务接口的,但你必须提供具体的邮件传输协议,客户端/服务器实现。我从未由ZMQ运输工具实现这一点,但是如果需要的话,应该是可能的。

As mentioned, the message content's format is up to you, but Google Protobuf might be appropriate for internally defined message protocols, that are supported for C++ and Java language bindings. Google Protobuf also provides a mechanism to define RPC service interfaces, but you must provide the concrete message transport protocols for client/server implementations. I have never implemented this by means of a ZMQ transport, but it should be possible if necessary.

XML / JSON-RPC可能会被视为出版(例如,通过REST服务)协议(桥接是相当容易ZMQ)。

XML/JSON-RPC might be considered for published (e.g. via REST services) protocols (bridging is considerably easy with ZMQ).

考虑你的要求,我猜后者协议格式选项不是必需的,但可能是有用的,虽然,这取决于框架,你会打算与Java / C ++参与者使用。

Considering your requirements, I'd guess the latter protocol format options aren't required, but might be useful though, depending on the frameworks you'll intend to use with the Java/C++ participants.

据我所知ZMQ相匹配的有关Windows XP / 7平台的可移植性约束。不知道,但也有可能是在Windows系统线程间通信的限制。但是,这似乎并不适用于你所描述的情况。

AFAIK ZMQ matches your portability constraints about Windows XP/7 platforms. Not sure, but there might be restrictions for inter-thread communication on Windows systems. But that doesn't seem to apply to the scenario you have described.

备选交通框架:


  1. 的ActiveMQ

  2. 升压ASIO (C ++包装了本地插座,我不知道关于Java方随意提高这些信息)

  1. ActiveMQ
  2. Boost asio (C++ wrapped native sockets, I don't know about the java side feel free to enhance this info)

备用邮件恩/解码框架:


  1. XML-RPC C ++ / java的(通常假定HTTP传输)

  2. JSON

  1. XML-RPC C++/java (usually assumes HTTP transport)
  2. JSON

这篇关于其中RPC /通讯框架将最适合这个案子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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