wagslane / go-rabbitmq

A wrapper of streadway/amqp that provides reconnection logic and sane defaults
https://blog.boot.dev/golang/connecting-to-rabbitmq-in-golang-easy/
MIT License
797 stars 129 forks source link

how to support rabbit mq consumer rebalance? #15

Closed xj-zh-dev closed 3 years ago

xj-zh-dev commented 3 years ago

I found that mq is very long, then start more consumers don't take effect.

Then, I restart old consumers, these new consumers begin to consume messages in the very long queue.

Does rabbitmq support rebalance? And how to support rabbit mq consumer rebalance?

pwli0755 commented 3 years ago

what do you mean by 'rebalance' here ?

It will be nice if you can provide demo code to reproduce your situation.

pwli0755 commented 3 years ago

If you want to keep the messages from mq equally distributed among all your consumers, Channel.Qos() is for you. See https://github.com/streadway/amqp/blob/master/channel.go#L613

xj-zh-dev commented 3 years ago

what do you mean by 'rebalance' here ?

It will be nice if you can provide demo code to reproduce your situation.

It's not the code issue, just occurs when consumers restart.

in Chinese: 在consumer重启的时候,很多消费者的时候,这时候消息队列有阻塞,后发的消息会被先处理一部分。

wagslane commented 3 years ago

Sounds like this isn't an issue? Open another one with more details if it's still a problem please.