JulianW
JulianW

Reputation: 907

ZeroMQ: link to message relation

I am using the ZMQ's Pub-Sub-Pattern. And I know it is possible to connect a subscriber to any number of publishers in order to receive with the ZMQ recv-function all the publisher messages over just one socket. However, I also need the information over which "link" (e.g. ipc:///tmp/link.ipc) I received the current received message.

Is there a way to query this information from the ZMQ message?

To help understanding what I mean, here a small example:

#include <zmq.hpp>
int main()
{
    zmq::context_t ctx(1);
    zmq::socket_t skt(ctx, ZMQ_SUB);
    skt.setsockopt(ZMQ_SUBSCRIBE, nullptr, 0);
    skt.connect("ipc:///tmp/link0.ipc");
    skt.connect("ipc:///tmp/link1.ipc");
    skt.connect("ipc:///tmp/link1.ipc");
    zmq::message_t msg;
    while (1)
    {
        if (skt.recv(msg))
        {
            // from which link is the message?
        }
    }
}

Upvotes: 0

Views: 82

Answers (1)

jamesdillonharvey
jamesdillonharvey

Reputation: 1042

There is no way to query that information from the zmq frame. Another option would be to publish multipart messages with an "part" containing the IP address or ID if address is too long.

Upvotes: 1

Related Questions