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