[zeromq-dev] sending messages to a specific peer

Martin Sustrik sustrik at 250bpm.com
Tue Dec 21 09:02:53 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.

If you want to speak to individual peers rather than managing a set of 
peers as an opaque resource, you should either use raw TCP instead of 
0MQ, or alternatively, you can create a separate 0MQ socket per peer.


More information about the zeromq-dev mailing list