Skip to content

Conversation

KingCide
Copy link

Which Issue(s) This PR Fixes

#9632

Fixes #9632

Brief Description

  1. topicCidMap是PopLongPollingService的一个核心数据结构,存储Topic下的消费者组映射,由两层map构成,内层map存储的key就是消费者组ID (ConsumerGroup/CID),在polling方法中被赋值。
  2. 借助这个数据结构,我设计了反向查找机制,避免了字符串解析的歧义问题
    a. 通过遍历topicCidMap中的所有topic-consumerGroup组合
    b. 对每个组合重建V1重试Topic名称,与输入的重试Topic进行匹配
  3. 当发现多个原始Topic都能生成相同的重试Topic时,标记为hasDuplicatedTopic
    a. 在有歧义的情况下,返回原始的重试Topic名称,避免错误的消息路由,不会因为Topic命名冲突导致消息通知错误(虽然如果有冲突,错误一定会发生的,但不会因为这段代码的修改引起)

How Did You Test This Change?

Copy link
Member

@lizhimins lizhimins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpu cost too much when there are many groups online

Use properties inside the msg to parser the originTopic.
@KingCide
Copy link
Author

Thanks! I have added "PROPERTY_ORIGIN_TOPIC" as a property inside a msg. The property can be used to parser the original topic name in retryTopic msg.

@KingCide
Copy link
Author

KingCide commented Aug 29, 2025

2025-08-29 11:19:14 INFO ReputMessageService - Processing retry topic: %RETRY%ConsumerGroup3_Topic, originTopic: Topic, properties: {ORIGIN_TOPIC=Topic, MSG_REGION=DefaultRegion, UNIQ_KEY=0106E51CE80829952C08C2B61F00000001, CLUSTER=DefaultCluster, 1ST_POP_TIME=1756437540244, PGROUP=Topic, RECONSUME_TIME=0, TAGS=Tag, __BORNHOST=U-6MCWWN14-2342.local, BORN_TIMESTAMP=1756437534442, KEYS=yourMessageKey-1c151062f96e, TRACE_ON=true}
2025-08-29 11:20:39 INFO ReputMessageService - Processing retry topic: %RETRY%ConsumerGroup2_Topic, originTopic: Topic, properties: {ORIGIN_TOPIC=Topic, MSG_REGION=DefaultRegion, UNIQ_KEY=0106E51CE80829952C08C2B62C0000000E, CLUSTER=DefaultCluster, 1ST_POP_TIME=1756437636658, PGROUP=Topic, RECONSUME_TIME=0, TAGS=Tag, __BORNHOST=U-6MCWWN14-2342.local, BORN_TIMESTAMP=1756437547648, KEYS=yourMessageKey-1c151062f96e, TRACE_ON=true}

This is the pop.log printed by my code.

if (topic.startsWith(prefix)) {
// 从properties获取原始topic名称
String originTopic = properties.get(MessageConst.PROPERTY_ORIGIN_TOPIC);
//根据原始topic和retryTopic,最后获得retryTopic对应的cid (可能还可以与topicCidMap验证一下)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete Chinese comments

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.
Thanks for your review.

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

Successfully merging this pull request may close these issues.

[Enhancement] Pop Long-polling Not Awakened for V1 Retry Messages

3 participants