检测 ZeroMQ 队列中丢弃的消息 [英] Detect dropped messages in ZeroMQ Queues

查看:39
本文介绍了检测 ZeroMQ 队列中丢弃的消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于似乎不可能查询/检查底层的 ZeroMQ 队列/缓冲区套接字以查看它们的使用量,是否有某种方法可以检测何时由于发布者套接字中的缓冲区已满而丢弃消息发送/排队?

Since it does not seem to be possible to query/inspect the underlying ZeroMQ queues/buffers sockets to see how much they are utilized, is there some way to detect when a message is dropped due to full buffers in a Publisher socket when sent/queued?

例如,如果发布者队列已满,zmq_send 操作将简单地丢弃消息.

For example, if the publisher queue is full, the zmq_send operation will simply drop the message.

基本上,我想要实现的是一种检测队列压力和/或已满的情况的方法,以便能够(稍后)调整解决方案以更好地工作.另一种方法是为每条消息添加一个序列号,并在订阅者中进行简单的计算,但我永远无法确定消息是否因发布者中的缓冲区已满而丢失.

Basically, what I want to achieve is a way to detect situations where the queues are getting stressed and/or full to be able to (later on) tune the solution to work better. One alternative way would be to add a sequence number to each message and do a simple calculation in the subscriber but I can never be sure that a message was lost due to full buffers in the publisher.

推荐答案

ZeroMQ 指南中有一个例子(如果你想愉快地使用 0MQ,你应该阅读和消化):http://zguide.zeromq.org/page:all#Slow-Subscriber-Detection-自杀蜗牛模式

There is an example for this in the ZeroMQ Guide (which you should read and digest if you want to use 0MQ happily): http://zguide.zeromq.org/page:all#Slow-Subscriber-Detection-Suicidal-Snail-Pattern

这个机制就像你自己回答的那样,在消息中添加一个序列号,并允许订阅者检测差距并采取适当的行动.对于大多数 pubsub 场景,您可以将默认 HWM(1,000)提高到更高的值;这取决于您的平均邮件大小.

The mechanism is as you answered yourself, to add a sequence number in the message, and allow the subscriber to detect gaps and take appropriate action. For most pubsub scenarios you can raise the default HWM, which is 1,000, to something much higher; it depends on your average message size.

这篇关于检测 ZeroMQ 队列中丢弃的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆