[zeromq-dev] Can a pub-sub endpoint have multiple publishers?

Randall Nortman rnzmq at wonderclown.net
Mon Apr 14 22:05:43 CEST 2014


I had the same requirement in my application.  You need a forwarding
device (either using the official ZMQ device or your own tiny bit of
code) to make this work.  Yes, you can have multiple PUBs connected to
a single SUB, but there is no way out of the box to connect multiple
PUBs to multiple SUBs.  So you have a daemon that binds both a PUB and
a SUB.  Senders connect a PUB to the daemon's SUB socket, and
receivers connect a SUB to the daemon's PUB, and the daemon just
forwards everything from its SUB to its PUB.

Instead of a SUB on the daemon, you can just as easily have a PULL
socket, and then the senders have a PUSH.  It's really pretty much the
same thing.  You can even do this with ROUTER/DEALER, but that offers
no advantages.  You must use a PUB socket on the daemon's send side,
because there is no other socket type that does fan-out (deliver one
message to multiple recipients).

-- 
Randall

On Mon, Apr 14, 2014 at 09:57:04PM +0200, Pieter Hintjens wrote:
> Reading the Guide is OK. Actually trying to examples and learning the
> basics is usually better. The answer to your question is, that's not
> quite how it works. You can connect all subscribers to all publishers,
> or you can create proxies in the center, but there is no such thing as
> a "pub sub endpoint" in a ZeroMQ network.
> 
> -Pieter
> 
> On Mon, Apr 14, 2014 at 7:27 PM, James Renkel <james at mfluent.com> wrote:
> > The communication pattern of our application is best described as a
> > "message bus": all messages sent by any "sender" on the bus are
> > delivered to all "receivers" on the bus.
> >
> > After having read the ZMQ guide, it seems that the "pub-sub" pattern is
> > the closet match to this, if a pub-sub endpoint can have multiple
> > publishers.
> >
> > I couldn't find anything that specifically prohibits this, but I also
> > couldn't find anything that specifically permits this.
> >
> > So the question is really simple: can a pub-sub endpoint have multiple
> > publishers, such that all messages published by any publisher will be
> > delivered to all subscribers?
> >
> > Has this been tried and is it known to work, or are will be be breaking
> > new ground here? We're not opposed to that, we just want to know what
> > we're getting ourselves in for.
> >
> > Thank you in advance for your attention to this.
> >
> > Jim Renkel
> > Senior Technical Staff
> > mFluent, Inc. LLC
> > mailto:james at mfluent.com
> > _______________________________________________
> > zeromq-dev mailing list
> > zeromq-dev at lists.zeromq.org
> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> _______________________________________________
> 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