fix: 避免 VIP 通知重放历史钱包事件

This commit is contained in:
zhx 2026-07-11 02:55:31 +08:00
parent 5bf372b78f
commit 3666a9ff02
2 changed files with 16 additions and 5 deletions

View File

@ -409,11 +409,9 @@ func walletOutboxUserLeaderboardConsumerConfig(cfg config.RocketMQConfig) rocket
}
func walletOutboxVIPRebateNoticeConsumerConfig(cfg config.RocketMQConfig) rocketmqx.ConsumerConfig {
consumerConfig := walletOutboxConsumerConfig(cfg, cfg.WalletOutbox.VIPRebateNoticeConsumerGroup)
// 新 consumer group 上线时必须从 broker 仍保留的最早事实恢复;否则 wallet/cron 先发布的
// 当日资格会永久没有系统通知。非目标钱包事实会被解析器安全跳过,不会写 inbox。
consumerConfig.ConsumeFromFirst = true
return consumerConfig
// VIP 返币通知会写用户 inbox属于不可批量重放的业务副作用。新消费组必须沿用 SDK 的
// latest-offset 默认值;上线窗口内需要补偿的少量资格由明确的位点重置处理,不能扫描全部历史钱包事实。
return walletOutboxConsumerConfig(cfg, cfg.WalletOutbox.VIPRebateNoticeConsumerGroup)
}
func messageActionProducerConfig(cfg config.RocketMQConfig) rocketmqx.ProducerConfig {

View File

@ -18,3 +18,16 @@ func TestRoomOutboxConsumerConfigSerializesCompositeProjection(t *testing.T) {
t.Fatalf("room outbox group = %q, want %q", consumerConfig.GroupName, cfg.RoomOutbox.ConsumerGroup)
}
}
func TestVIPRebateNoticeConsumerDoesNotReplayHistoricalWalletEvents(t *testing.T) {
cfg := config.Default().RocketMQ
cfg.WalletOutbox.VIPRebateNoticeConsumerGroup = "activity-vip-rebate-notice-test"
consumerConfig := walletOutboxVIPRebateNoticeConsumerConfig(cfg)
if consumerConfig.ConsumeFromFirst {
t.Fatal("VIP rebate notice consumer must start at the latest offset for a new group")
}
if consumerConfig.GroupName != cfg.WalletOutbox.VIPRebateNoticeConsumerGroup {
t.Fatalf("VIP rebate notice group = %q, want %q", consumerConfig.GroupName, cfg.WalletOutbox.VIPRebateNoticeConsumerGroup)
}
}