【RabbitMQ】RabbitMQ监控 Message rates 一直有波动,但是 Queued messages 没有任何消息

问题

  • Queued messages : 统计消息的条数一直为 0

  • Message rates:统计消费的速率一直有数据

  • 数据库数据已经入库,表示消息确实被消费了。

总体

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-UrhiHrJo-1578625107928)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200109143814487.png)]

明细

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-snoBZZle-1578625107929)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200109145417251.png)]

通过手动的方式发送消息,也不能统计到。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-JtpOYCun-1578625107930)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200109152103127.png)]

但是关闭消费者程序之后,手动发送消息就可以统计到了

继续排查

那么手动加一个队列 test.queue
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-VW6r0DuH-1578625107930)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200109153935299.png)]

手动发一条消息,发现正常显示
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-dUzpx6QE-1578625107931)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200109153904706.png)]
继续测试
将生产者修改为 每100毫秒发送100条消息,发送5次

    @RequestMapping("/test")
    @ResponseBody
    public Integer test(Integer id) throws InterruptedException {
        int count = 0;
        for (; ; ) {
            if (count == 5) break;
            for (int i = 0; i < 100; i++) {
                gupaoTemplate.convertAndSend("GP_DIRECT_EXCHANGE", "test", "消息" + i);
                System.out.println("消息" + i);
            }
            Thread.sleep(100);
            count++;
        }

        return 1;
    }

消费者修改为 每消费一条睡眠100毫秒,设置了手动签收,消费完最后签收。

扫描二维码关注公众号,回复: 12634353 查看本文章
@Service
public class TestConsumer {
    @RabbitListener(queues = "test.queue")
    public void saveQuotaComment(Message message, Channel channel) throws InterruptedException, IOException {
        Thread.sleep(100);
        System.out.println(">>>>>>>>>>>>>>>>>>>"+new String(message.getBody()));
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
}

样保证消费者的消费速度跟不上消息的生产速度。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-JQmGTI2f-1578625107932)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200110105716664.png)]

Queued messages 终于有数据。

总结

Queued messages 显示的是消息堆积之后的监控数据,并非所有的消息都会记录在里面,如果消息消费的过快,不会有数据显示。

感谢咕泡学院-青山老师的帮助,贴上青山老师的回答。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Xpy7kOEx-1578625107932)(C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20200110105801895.png)]

参考文章

https://blog.csdn.net/xiewenfeng520/article/details/103920971

猜你喜欢

转载自blog.csdn.net/xiaoxiao_su123/article/details/112858722