N to N async pattern in ZeroMQ?
Asked Answered
O

3

8

although I went through the guide I cant find a way to do the following:
we have n publishers,
we have m subscribers.
Each subscriber subscribes to certain type of msg(one publisher can send more than one kind of the message, multiple pubs can emit msgs of same type).
How to create N to N(or N to 1 to N) pattern in 0MQ that does that?

Orthoepy answered 4/9, 2012 at 13:2 Comment(5)
i smell a down vote. "what have you tryied?"Eatables
guide examples, simple ones are easy to do, but there is not a single N to N in exmples, beside one that is useless to me(Extended Request-reply) - I need one way communicationOrthoepy
In other words, you're asking how to implement ROS topics in zeromq.Glenine
The usual crap of "you can have multiple subscriber to a publisher". You DON'T KNOW THE FING PUBLISHER. The publisher is a CLUSTER. You don't address "A" publisher, you address a CLUSTER of it. This seems to be a concept too fing difficult for the masses. Every god damn diagram about this situation in 0MQ either has a single node in there doing proxy/pubsub/whatever or a "multicast UDP". None of which solves any problem with N to N peer connection.Probative
I've asked kinda the same question, but with a code example: #49488635Astrograph
S
2

Pattern? A publisher will accept any number of subscribers, and your subscribers can connect to multiple publishers. I don't see any issue here, just go ahead and do it.

In the future, perhaps you'll be better served by stating what you want to accomplish, rather than how you think it should be done. Just hooking up a bunch of subscribers to a bunch of publishers might not be the best way to go about whatever it is that you're doing.

Sternpost answered 4/9, 2012 at 14:23 Comment(2)
I want to have a set of publishers and set of subscribers. But subscribers dont subscribe to publisher X, but to a tag of msg. Also I want it async.Orthoepy
@NoSenseEtAl: Ok. Please explain how any of that conflicts with what I said above.Sternpost
L
2

0MQ automatically allows N to M networks; just connect each subscriber to each publisher. That can become a burden to manage, in which case you can use a simple proxy that all publishers and subscribers connect to, see http://zguide.zeromq.org/page:all#toc36.

Loricate answered 11/9, 2012 at 2:36 Comment(2)
That link is broken; search for the wuproxy example. You end up with something like 7 threads participating in transferring each message (Sender -> PUB socket -> SUB socket -> proxy -> PUB socket -> SUB socket -> Receiver), and you still have to handle serialization and filtering on message types yourself, so zmq isn't currently a replacement for a middleware like ROS (although you could write one on top of zmq)Glenine
And how do you "connect to each publisher"? Think AWS auto scaling group. Querying for IP address, connecting to each of them and coordinating for when message starts getting sent, adding/removing new publishers as they come and go. No. Pass.Probative
D
0

I have done a simple example in C which uses the built in zmq forwarder device to forward messages from N publishers to N subscribers. The code is available at https://gitorious.org/hellozmq

Denounce answered 10/1, 2013 at 16:40 Comment(2)
Thanks but no thx. When that single box goes down, everything goes down. Next.Probative
Ok but if single point failure is the main concern. All N Subscribers can connect directly to N Publishers and the broker can act as a directory service.Denounce

© 2022 - 2024 — McMap. All rights reserved.