简体   繁体   English

我可以使用什么库来进行简单,轻量级的消息传递?

[英]What library can I use to do simple, lightweight message passing?

I will be starting a project which requires communication between distributed nodes(the project is in C++). 我将启动一个需要在分布式节点之间进行通信的项目(该项目使用C ++)。 I need a lightweight message passing library to pass very simple messages(basically just strings of text) between nodes. 我需要一个轻量级的消息传递库来传递节点之间非常简单的消息(基本上只是文本字符串)。 The library must have the following characteristics: 该库必须具有以下特征:

  1. No external setup required. 无需外部设置。 I need to be able to get everything up-and-running in my code - I don't want to require the user to install any packages or edit any configuration files(other than a list of IP addresses and ports to connect to). 我需要能够在我的代码中启动并运行所有内容 - 我不想要求用户安装任何软件包或编辑任何配置文件(除了要连接的IP地址和端口列表)。

  2. The underlying protocol which the library uses must be TCP(or if it is UDP, the library must guarantee the eventual receipt of the message). 库使用的基础协议必须是TCP(或者如果它是UDP,则库必须保证最终接收消息)。

  3. The library must be able to send and receive arbitrarily large strings(think up to 3GB+). 该库必须能够发送和接收任意大的字符串(最多3GB +)。

The library needn't support any security mechanisms, fault tolerance, or encryption - I just need it to be fast, simple, and easy to use. 该库不需要支持任何安全机制,容错或加密 - 我只需要它快速,简单和易于使用。 I've considered MPI, but concluded it would require too much setup on the user's machine for my project. 我考虑过MPI,但总结说在我的项目用户的机器上需要设置太多。

What library would you recommend for such a project? 你会为这样一个项目推荐什么样的图书馆? I would roll my own, but due to time constraints, I don't think that will be feasible. 我会自己动手,但由于时间限制,我认为这不可行。

看看ØMQ ,即ZeroMQ。

Apache Qpid implements server and client libraries for Advanced Message Queuing Protocol . Apache Qpid高级消息队列协议实现服务器和客户端库。 It has many features, from which you can use the following: 它有许多功能,您可以使用以下功能:

  1. Client can connect anonymous on the broker, specifying broker's IP/port 客户端可以在代理上连接匿名,指定代理的IP /端口
  2. Transport protocol is TCP or SCTP 传输协议是TCP或SCTP
  3. It has support for large messages using either pull style or push style semantics 它支持使用拉式或推式语义的大型消息
  4. It's fast 很快
  5. Usage is simple and available in C++: 用法很简单,可以在C ++中使用:

I use nanomsg for my distributed system. 我将nanomsg用于我的分布式系统。 nanomsg is stable, mature, well supported light-weight messaging protocol library written in C. nanomsg是一个稳定,成熟,支持良好的轻量级消息传递协议库,用C语言编写。

It fulfills all your requirements: 它满足您的所有要求:

1)  There is no external setup required
2)  TCP underlying protocol is a primary one. 
3)  Message sizes supported by nanomsg are expressed as a 64-bit integer.
 (The default message size is 1024kB. This can be easily changed by API call to 
 support any size. The maximum size is limited only by available addressable memory!)

The other good library to consider is nng . 要考虑的另一个好的库是nng It is in betta stage now. 现在处于斗鱼阶段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM