Search code examples
message-queuezeromqdistributed-computing

ZeroMQ Dealer to Dealer - work distribution


Consider the following setup. I connect() multiple DEALER sockets (clients) to another DEALER, bound to an address (server). Exactly one of the clients calls recv() in a loop, while the other clients may occasionaly send something to the server.

Will the server socket try to distribute sent messages to those clients that don't receive anything? I couldn't find how exactly dealer sockets deal with work distribution in the ZeroMQ Guide nor in the zmq_socket manpage.

I use ZMQ 4.1.


Solution

  • Not all versions of ZeroMQ work the same way

    The safe way is to check the respective version API man-page for details. Not all projects may use the latest API, due to interoperability reasons when any of the counterparties simply does not have any newer version API binding available. Then the oldest one rulez the crowd.

    ZeroMQ 2.1.11 API does not permit DEALER/DEALER
    ZeroMQ 4.2.0 API does

    In any case, API man-pages are always a worth source of details:

    4.2.0
    ZMQ_DEALER
    A socket of type ZMQ_DEALER is an advanced pattern used for extending request/reply sockets. Each message sent is round-robined among all connected peers, and each message received is fair-queued from all connected peers.

    When a ZMQ_DEALER socket enters the mute state due to having reached the high water mark for all peers, or if there are no peers at all, then any zmq_send(3) operations on the socket shall block until the mute state ends or at least one peer becomes available for sending; messages are not discarded.

    When a ZMQ_DEALER socket is connected to a ZMQ_REP socket each message sent must consist of an empty message part, the delimiter, followed by one or more body parts.

    Summary of ZMQ_DEALER characteristics

    Compatible peer sockets:      ZMQ_ROUTER, ZMQ_REP, ZMQ_DEALER
    Direction:                    Bidirectional
    Send/receive pattern:         Unrestricted
    Outgoing routing strategy:    Round-robin
    Incoming routing strategy:    Fair-queued
    Action in mute state:         Block