简体   繁体   English

记录发送总数和手动统计的已发送消息数之间的差异

[英]Difference between record-send-total and manually counted number of sent messages

I have a producer that sends messages for 15 second.我有一个发送消息 15 秒的生产者。 I wanted to investigate the total number of messages sent to the broker.我想调查发送到代理的消息总数。 The first method I employed involved counting messages "manually", ie:我采用的第一种方法涉及“手动”计数消息,即:

// ...
private int sentMessages = 0;

@Override
public void run() {
   sendMessage(msg));
   sentMessages++;
}

The second method I used involved analysing the producer's metrics.我使用的第二种方法涉及分析生产者的指标。

I compared the number of produced messages, and significantly different results I observed baffled me.我比较了产生的消息的数量,我观察到的明显不同的结果让我感到困惑。 sendMessages was equal to 65243 whereas the producer's record-sent-total was equal 47883 . sendMessages等于65243 ,而生产者的record-sent-total等于47883

What might be the reason behind such a great difference between them?他们之间如此巨大差异背后的原因可能是什么?

I believe sendMessage(msg) processing in asynchronous way.我相信 sendMessage(msg) 以异步方式处理。 So some message might failed to send.所以有些消息可能无法发送。 Try to update sentMessages count based on successful response.尝试根据成功响应更新 sentMessages 计数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM