Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教,消费方式用法 #1176

Open
eddatt opened this issue Oct 25, 2024 · 0 comments
Open

请教,消费方式用法 #1176

eddatt opened this issue Oct 25, 2024 · 0 comments

Comments

@eddatt
Copy link

eddatt commented Oct 25, 2024

您好,我有以下使用场景:
多实例拉取消费,每条消息全局仅消费一次,并且顺序消费
比如有10条消息,ID:0-9,当前两个实例,希望每个实例能每次拉取都获得下一个全局未消费的消息,理想情况下,id 02468被一个实例消费,id 13579 被另一个实例消费

我按照文档尝试:
1.poll 方法:两个实例情况下,一直只会有一个实例在消费,另一个实例完全拿不到消息
2.pull 方法:两个实例情况下,一个实例会重复获取同一条消息,不知道怎么ack
3.pullfrom 方法:rmq配置3broker,每个broker两个queue情况下,生产的消息只会打到6个中的一个(很奇怪),然后我pullfrom 会调用6次,每次设置1s超时(这个遍历一遍的成本很高),两个实例情况下,这两个实例都能拿到全部消息,然后我用redis去重,保证每个消息只消费一次

目前只有pullfrom 6次+redis方法跑通了要求,但是额外耗时太高了,我觉得是不是哪里没有用对,小白求教,十分感谢

这里是创建consumer代码:
nameServer, err := primitive.NewNamesrvAddr(NameServerAddr) if err != nil {} newPullConsumer, err := rocketmq.NewPullConsumer( consumer.WithGroupName(GroupName), consumer.WithNameServer(nameServer), consumer.WithAutoCommit(true), consumer.WithConsumerModel(consumer.Clustering), consumer.WithMaxReconsumeTimes(1), )

补充:
创建的consumer,打印出来显示的BroadCasting模式,请问是为什么
{"GroupName":"","Model":0,"UnitMode":false}

&{defaultConsumer:0xc000324e00 topic: selector:{Type: Expression:} GroupName: Model:BroadCasting UnitMode:false nextQueueSequence:0 allocateQueues:[] done:0xc0004404e0 closeOnce:{done:0 m:{state:0 sema:0}} consumeRequestCache:0xc0001b70e0 submitToConsume:0x981460 interceptor:}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant