8

In a REQ/REP socket, if the socket send a request to a dead (disconnected) node the message isn't delivered and stays in a message queue occupying memory. How can one clean these undelivered messages (let's say, messages that are in the queue for more than 1 minute)?

Thanks!

carlosalbertomst
  • 513
  • 6
  • 18

1 Answers1

4

You might want to set the optional parameter ZMQ_LINGER:

The ZMQ_LINGER option shall set the linger period for the specified socket. The linger period determines how long pending messages which have yet to be sent to a peer shall linger in memory after a socket is closed with zmq_close(3), and further affects the termination of the socket's context with zmq_term(3).

... for which a positive value will set a maximun time for message to be blocked in the queue.

See http://api.zeromq.org/2-1-1:zmq-setsockopt

Manuel Salvadores
  • 16,287
  • 5
  • 37
  • 56
  • Doesn't that only apply to the local socket (which hasn't been closed)? The question is about when the remote peer has terminated - but the local socket is still alive, surely? – DNA May 12 '11 at 19:45