You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

RabbitMQ消费者消费百万空消息但管理UI不可见问题求助

RabbitMQ消费者批量消费空消息异常排查

我用Go编写了一个多队列RabbitMQ消费者,代码如下:

queues := []string{"foo", "bar", "baz", "qux"}
for _, queue := range queues {
    go func(queue string) {
        var channel *amqp.Channel
        var notifyClose chan *amqp.Error
        for {
            channel, notifyClose = rabbit.DeclareChannel()
            channel.Qos(
                1,    // prefetch count
                0,    // prefetch size
                true, // global
            )
            rabbit.DeclareQueue(channel, queue)
            messages, err := channel.Consume(
                queue, // queue
                queue, // consumer - set the same as queue
                true,  // auto-ack
                false, // exclusive
                false, // no-local
                false, // no-wait
                nil,   // args
            )
            // read from messages in a continous loop 
        Loop:
            for {
                select {
                case err = <-notifyClose: // listen for RabbitMQ channel errors
                    break Loop // re-establish the channel - have to use label for break from loop, not from case
                case msg := <-messages:
                    log.Info("Received message", zap.String("queue", queue), zap.String("message", string(msg.Body)))
                }
            }
        }
    }(queue)
}

该应用在多数客户环境运行正常,但某使用PaaS自有RabbitMQ的客户出现异常:部署的两个消费者节点每日(有时多次)同时从部分队列消费数百万条空消息,异常特征如下:

  • 两个节点同时触发空消息消费
  • 异常涉及的队列不固定,但双节点均从相同队列消费空消息
  • RabbitMQ管理UI仅显示正常非空消息,这些消息因节点忙于消费空消息被阻塞
  • 临时修复需重启RabbitMQ服务器或所有节点,仅重启单个节点无法彻底解决
  • 其他使用独立RabbitMQ服务器的客户无此问题

客户无法访问RabbitMQ日志,仅能查看管理UI,认为问题出在消费者节点,目前未找到同类案例参考,需排查问题根源。


内容的提问来源于stack exchange,提问作者costinmrr

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 01:52:28