[zeromq-dev] sending messages to a specific peer

mike castleman m at mlcastle.net
Mon Dec 20 20:50:38 CET 2010


I have an application where the server needs to send occasional messages
to a specific peer (because the peers control individual,  distinct, and
geographically distributed hardware resources).

The obvious solution is a ZMQ_PUB/ZMQ_SUB pair with a unique topic per
client, but my understanding is that in such a case the all messages are
in fact distributed to all subscribers and the filtering happens only on
the subscriber's side. Given the network topology and limited bandwidth
of the clients in our application, this is unsuitable.

One solution which may work is to use XREP/XREQ sockets: the client sets
its identity on connect and then proceeds to ignore the usual REP/REQ
pattern in favor of just waiting for messages from the server. A minimal
implementation of this pattern (in Ruby) is at
<https://gist.github.com/748886>. This seems to work, but it also seems
like an abuse of XREP/XREQ.

Any thoughts on this problem? Should I use the XREP/XREQ pattern
described here, or is there something better that I am overlooking? If
this problem is well-known and has already been discussed, then pointers
to such previous discussion would be much appreciated.

thanks a lot!


mike castleman
mailto:m at mlcastle.net

More information about the zeromq-dev mailing list