[zeromq-dev] PUB/SUB with multiple publishers

Matt Weinstein matt_weinstein at yahoo.com
Fri Jul 16 22:12:46 CEST 2010


This may give you what you want, however since sockets are single  
threaded you'll have create separate publisher and subscriber threads,  
or have your service thread poll() multiple sockets.

Meanwhile -- please note below -- I left out the SECOND inproc:  (you  
need two -- one for each end of the device).

Look at the device code in the zeromq src, they're pretty trivial.

Best,

Matt

On Jul 16, 2010, at 3:26 PM, Dmitri Toubelis wrote:

> Thanks Matt,
>
> I will try your suggestion. There is not much documentation on  
> devices, so
> it looks like I need to dig into the code.
>
> What I'm trying to achieve here is N-way communication scheme,  
> something
> analogous to direct exchange in AMQP. The way I was thinking was to  
> create N
> nodes that could publish to the same bus and have subscribers, that  
> only
> receive messages directed to them. Each node is both publisher and
> subscriber, it receives message from the bus and depending on  
> workflow sends
> it to other subscribers using proper subscription key. So, I'm  
> expecting to
> have 4+ publishers on the bus and equal number of subscribers. It is
> straightforward to do using AMQP but I'm still not sure what is the  
> proper
> ZMQ way for this.
>
> Dmitri
>
> ________________________________
>
> From: zeromq-dev-bounces at lists.zeromq.org
> [mailto:zeromq-dev-bounces at lists.zeromq.org] On Behalf Of Matt  
> Weinstein
> Sent: July 16, 2010 2:56 PM
> To: 0MQ development list
> Subject: Re: [zeromq-dev] PUB/SUB with multiple publishers
>
>
> I think your PUB from the second publisher went to the first  
> publisher at
> the other end of the pipe ?
>
> You might try using a device() to connect two sets of sockets back- 
> to-back,
> just like the server example.
>
> I believe you'd do something like
>
> create "inproc://pubsource"
> device:
> bind as a SUB
> subscribe to all ("")
> publishers:
> connect as a PUB
>
> on the other side:
create "inproc://pubsink"
> device:
> bind as a PUB
> subscribers
> connect as a SUB
> subscribe to all ("")
>
> I think the "one way" device can be used as a model, you're only  
> going one
> way :-)
>
> On Jul 16, 2010, at 2:06 PM, Dmitri Toubelis wrote:
>
>
> 	I call bind only once. The second time I use connect and it returns
> 0.
> 	
> 	Dmitri Toubelis
> 	Solution Architect / Director @ Alkeron Multimedia
> 	cell: +1-647-400-3876
> 	email: dmitri.toubelis at alkeron.com
> <mailto:dmitri.toubelis at alkeron.com>
> 	
>
> ________________________________
>
> 	From: zeromq-dev-bounces at lists.zeromq.org
> [mailto:zeromq-dev-bounces at lists.zeromq.org] On Behalf Of Chuck Remes
> 	Sent: July 16, 2010 1:48 PM
> 	To: 0MQ development list
> 	Subject: Re: [zeromq-dev] PUB/SUB with multiple publishers
> 	
> 	
> 	On Jul 16, 2010, at 12:34 PM, Dmitri Toubelis wrote:
>
>
> 				I have a scenario when I need to use PUB/SUB
> scheme with multiple publishers. Is it possible to do with "inproc"
> transport?
> 		
> 		Here is what I tried:
> 		- create PUB socket and bind it to "inproc://pipe" endpoint
> 		- create another PUB socket and connect it to the same
> "inproc://pipe" endpoint
> 		- create SUB socket for each subscriber and connect them to
> thre "inproc://pipe" endpoint.
> 		- publish message using second publisher.
> 		
> 		I'm getting no error, but message is not getting delivered
> to subscribers. Am I doing something wrong?
> 		
>
> 	I don't think it is possible to have multiple sockets bind to the
> same endpoint. Are you certain that the result code from calling  
> bind is 0?
> If it is, then this is likely a bug and should be reported (with  
> sample
> code).
>
> 	Alternately, if you are running this on Windows then I don't think
> inproc or ipc transports are supported on that platform. That should  
> also
> error out (if you are on Windows).
>
> 	cr
>
>
> 	_______________________________________________
> 	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