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开发者_JS百科 can one clean these undelivered messages (let's say, messages that are in the queue for more than 1 minute)?
Thanks!
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
精彩评论