在 REQ/REP 套接字中,如果套接字向死(断开连接)节点发送请求,则消息不会传递并停留在占用内存的消息队列中。如何清理这些未送达的消息(比方说,队列中超过 1 分钟的消息)?
谢谢!
最佳答案
您可能希望设置可选参数 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).
... 正值将设置消息在队列中阻塞的最大时间。
看
http://api.zeromq.org/2-1-1:zmq-setsockopt
关于sockets - ZeroMQ 设计决策,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3816373/