8

在 REQ/REP 套接字中,如果套接字向死(断开连接)节点发送请求,则消息不会被传递并停留在占用内存的消息队列中。如何清理这些未传递的消息(比如说,队列中超过 1 分钟的消息)?

谢谢!

4

1 回答 1

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

于 2011-03-31T14:01:55.100 回答