Zeromq哪个套接字应绑定在PubSub模式上 [英] Zeromq which socket should bind on PubSub pattern

查看:167
本文介绍了Zeromq哪个套接字应绑定在PubSub模式上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读有关ZeroMQ的详细信息,尤其是有关NetMQ的信息,以及我看到的几乎每个用于绑定Publisher套接字的Pub/Sub示例,然后Subscriber套接字都连接到另一个.

I have been reading about ZeroMQ more specifically about NetMQ and almost every Pub/Sub examples I saw used to Bind the Publisher socket and then the Subscriber socket connects to the other.

所以我想知道是否有可能做相反的事情,我的意思是绑定订户套接字,然后发布者连接到它.

So i'm wondering if it is possible to do the reverse, i mean Bind the Subscriber socket and then publishers connect to it.

这可能吗? (我在文档中没有发现任何明确的内容) 使用此连接策略有哪些缺点?

Is this possible ? (I didn't found anything clear on documentation) What are the disadvantages using this connection strategy ?

任何帮助都会有用.

推荐答案

是的,您可以将其反转,并且使用该连接策略没有任何缺点...只要它适合您的目的.

Yes, you can reverse it and there are no disadvantages to using that connection strategy... provided it suits your purpose.

在ZMQ中,绑定"和连接"背后的驱动概念是:一侧通常被认为更可靠(并且通常会有更少的节点),而另一侧则被认为更具瞬态性(并且可能会有更多的节点).可靠的一面将被视为您的服务器",并且您应该在那一侧bind(),瞬态一面将被视为您的客户端"(或客户端 s ),并且您应connect()在那一边.

In ZMQ, the driving concept behind "binding" and "connecting" is that one side is often considered to be more reliable (and usually there will be fewer nodes), and the other side is considered to be more transient (and there could be more numerous nodes). The reliable side would be considered your "server", and you should bind() on that side, the transient side would be considered your "client" (or clients), and you should connect() on that side.

通常,我们认为稳定的服务器"将信息不断发布给可能出现的许多客户端"订户.在您看到的示例中对此进行了表示:在pub上绑定,在sub上连接.

Typically, we think of a stable "server" publishing information constantly, to many "client" subscribers which may come and go. This is represented in the examples that you see: bind on pub, connect on sub.

但是,您可以很容易地获得一个稳定的服务器",以订阅连接到该服务器的许多客户端"发布者的任何输出,并在它们可用时接受其发送的任何信息.绑定到子,连接到发布.

But, you could just as easily have a stable "server" subscribing to any output from many "client" publishers that connect to it, accepting any information that they're sending while they are available. Bind on sub, connect on pub.

您也不限于一台服务器,这只是最简单的示例-但是,如果您在同一台计算机上运行所有套接字,则会受到更大的限制.在同一地址上绑定多个套接字会产生冲突,但是您可以根据需要将多个套接字连接到同一地址.

You're not limited to one server, either, it's just the simplest example - however, you're more limited if you're running all of your sockets on the same computer. Binding on the same address with more than one socket will produce a conflict, but you can connect as many sockets to the same address as you like.

在许多情况下,通信的双方实际上都是可靠且长期运行的,在这种情况下,将发送信息的节点视为服务器,将接收信息的节点视为客户端很有用.在这种情况下,我们返回绑定在pub上,在sub上连接.

In many cases, both sides of the communication are really intended to be reliable and long running, in which case it's useful to think of the node which sends the information as the server, and the one which receives it as the client. In which case, we're back to bind on pub, connect on sub.

这篇关于Zeromq哪个套接字应绑定在PubSub模式上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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