I'm new to ZeroMQ, (and programming with sockets in general), but am trying to implement (in Java) a peer-to-peer model in ZeroMQ. What I would like is for when a node comes on-line, it broadcasts to the entire network an "I'm here, and you can reach me at this address:..." message.
I'm thinking that if 2 or more nodes appear on the network, they would be able to find each other without having to go through a known endpoint.
Does anyone have any ideas on how I could achieve this? Is this even possible with ZeroMQ?
What you're asking for cannot be done with zmq. There is no mechanism (without a known and defined endpoint) that allows you to 'know' when a publisher comes online and its messages are ready for subscribing to.
That being said, it is quite trivial to set something of this sort up using a XPub and XSub router(which requires a known endpoint). You can also create your own 'endpoint' that all clients connect to using a REQ/REP socket. This will allow you to have a central (essentially a directory service) that you can then connect point to point subscribe/publish connections (which will keep your network duplication at its lowest).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With