[zeromq-dev] Socket identities with subscription messages

Stefan Radomski radomski at tk.informatik.tu-darmstadt.de
Wed Nov 28 14:07:05 CET 2012

On Nov 28, 2012, at 12:23 PM, Pieter Hintjens <ph at imatix.com> wrote:

> It would help if you explained your problem and what you are actually
> using subscriber identities for.

We are in the process of implementing a rather pragmatic, distributed pub/sub middleware using mDNS (Bonjour & Avahi) for node discovery and ZeroMQ as a message broker[1]. On top of the ZeroMQ and mDNS concepts, we offer node, publisher and subscriber abstractions and we would ultimately like our publishers to "know" their subscribers (e.g. in order to wait for a subscriber with a given UUID). 

All relevant meta-information (foremost available publishers on a node) is submitted via fully meshed DEALER/ROUTER pairs between the nodes (discovered via mDNS and using their UUID as the socket identity). For pub/sub, we use the extended publish/subscribe (figure 14 in the guide) per node. Therefore, each node has one public XPUB and a public ROUTER socket and a number of subscribers with unbound PUB sockets connected to XPUB socket as required.

The problem arises because I cannot know whether a given subscriber (identified in our abstractions per UUID) was actually connected to a publisher per ZeroMQ as I only see *a* subscription on the XPUB socket which might be from any other subscriber as well.

> There is no logical step except to
> solve real problems in the simplest plausible way.

With logical next step I meant that ZMQ_XPUB_VERBOSE allows a publisher to know the *number* of subscribers and envelopes would allow to know their *identity* as well. Thus the hack with using a subscribers prefixed UUID: at least I would know that the SUB socket sent all its actual subscriptions when I receive a prefixed UUID on the XPUB socket and could confirm its existence to the publisher abstraction.

Best regards

[1] https://github.com/tklab-tud/umundo/

P.S.: the code on github does not yet reflect socket layout as described above, I am in the process of refactoring.

> The protocol does in fact support identity exchange for all socket
> types but what are the semantics in XSUB/XPUB? In ROUTER, it's used to
> route replies.
> I'm sceptical of extending pub/sub much further since it breaks the
> scalability of the pattern but as we've said often, if it's something
> you want to make, send a patch.
> -Pieter
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

More information about the zeromq-dev mailing list