jbulatek
jbulatek

Reputation: 164

Where does zmq_send() send with multiple connections?

Let's say I have ZMQ_PUSH socket, connected to multiple peers and I use zmq_send() to send something through these sockets.

I am looking for couple hours now and I can't find in the ZMQ documentation where my message will be sent.

The reasonable assumption is, that it will be sent to all connected peers, but they're saying, that round-robin algorithm is in use, what confuses me a little. Does it mean I should send same message as many times as I have connections?

Upvotes: 0

Views: 439

Answers (1)

user3666197
user3666197

Reputation: 1

Q : "Where does zmq_send() send with multiple connections?"

It does send messages depending on what of the actual Archetype is used.

PUB/SUB sends each message to all peers that are positively subscribed to a Topic ( left-side, binary matching of the payload as-string ), whereas some internal details in pre-v3 releases actually physically moved any message to all peers (and there the SUB-side Context()-instances, kind of ALAP, performed the Topic-filtering ), not so since v3+.

PUSH/PULL does not have this "promise", so better try to imagine the PUSH-side to be a job-queue commander, and each PULL-side worker receives ( in the round-robin manner here ) a next task from the job-queue, as the load-balancers do in common.

Each other of the built-in Archetypes - REQ/REP, XPUB/XSUB, DEALER/ROUTER, PAIR/PAIR, ... - have a similarly formulated "promised-behaviour", so ZeroMQ services can build on combining these trivial Archetypes into some more complicated & structured group-behaviours for messaging/signalling applications.

Q : "The reasonable assumption is, that it will be sent to all connected peers"

If it were this way, there would be lost the key property of the PUSH/PULL "promised-behaviour" and there would be no difference between this and a PUB/SUB Archetype ( which makes even less sense to develop two things that do the very same thing, doesn't it? )

Upvotes: 1

Related Questions