nanomsg

multiple publishers & subscribers in nanomsg (nng)


How does one setup multiple publishers & subscribers with a TCP transport. I suspect that you don't do automatic mesh/bus creation. So one needs a unique IP bind point for each publishers, right? They just have the subscribers connect to each publisher on a single socket.

(this was discussed in: https://www.freelists.org/post/nanomsg/does-nanomsg-support-multi-producer-in-pubsub-mode,10 )

Is that basically correct?

The reason I lean to a pub/sub over a bus/mesh approach is because (and I admit I might well be mistaken) -

Basically what I have is 2 producers (that mainly do publishing, but can receive occasional requests to put additional info on the stream being published, so they do need to listen) And then about five consumers who mainly do receipt of the data stream from the publishers, but do need to occasional send requests to the producers.

And yes, I want the pub to be async, as as well as the recv() for the subscribe (no blocking is allowed in the context where I am using this).

So this is a bi-directional pub/sub architecture. And I am looking at the simplest way to implement this. (traffic is pretty light).


Of course a UDP transport would be nice for this, but I am not holding by breath.


Solution

  • NanoMSG NNG is very symmetric and orthogonal. I had a couple discussions with gdamore.

    Each Endpoint can be push, req, bus, or whatever You can have multiple endpoints (e.g. 2 push, or a push and req/res) Protocol can be in either direction Rec can be blocking, async, or poll based.

    If you want to see how to do this, see:

    https://github.com/nanomsg/nng/issues/551