我正在使用 ZeroMQ 发布订阅套接字来连接两个进程。发布过程是一个传感器,刷新率比订阅过程快得多。我希望订阅过程只使用队列中的最新消息——并完全忽略旧消息。
我试过在订阅者上设置一个高水位标记,但这似乎会丢弃较新的消息而不是较旧的消息。
是否有人可以为此目的指导我使用发布 - 订阅模式?
最佳答案
从 documentation on zeromq 阅读有关合并功能的信息(这是一种新的),我认为这正是您想要的。
从文档:
ZMQ_CONFLATE: Keep only last message If set, a socket shall keep only one message in its inbound/outbound queue, this message being the last message received/the last message to be sent. Ignores 'ZMQ_RCVHWM' and 'ZMQ_SNDHWM' options. Does not support multi-part messages, in particular, only one part of it is kept in the socket internal queue.
关于ZeroMQ:我希望发布-订阅删除旧消息以支持新消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25940962/