Search code examples
network-programmingzeromqpolicy

ZeroMQ: Internal queuing policy before having a valid connection


Say if I have an inproc-PAIR messaging system. Before the Receiver connects to the Sender, the Sender is already bound and starts sending out messages right away.

Now, before the connection succeeds, will ZMQ choose to do one of the following:

  • queue up those messages internally
  • block Sender from sending those messages
  • simply discard them?

I know that ZMQ has an internal queue of 1000 messages, and read that with PubSub it will send out messages right after binding happens and thus will lose messages. But I'm not sure about other protocols.


Solution

  • From the ZeroMQ documentation :

    When a PAIR socket enters the mute state due to having reached the high water mark for the connected peer, or if no peer is connected, then any send operations on the socket will block until the peer becomes available for sending; messages are not discarded.

    So your first two options are correct; it's queuing messages till you reach hwm then blocks the sender. It is not dicarding messages.