feat(worker): 五个消费者改用 ConsumeLoop 分派重试与停泊

每个 worker 的 Run 只保留参数校验。消费循环统一由 rabbitmq.ConsumeLoop 驱动。
因此重试、停泊、Ack 的规则只有一份实现。

坏消息一律标记 rabbitmq.Permanent。因此解析失败与未知 action 立即停泊。
未知 action 不再被静默 Ack 丢弃。

notification worker 改按队列与 body.action 分派。重试回源会把 routing key
改写成队列名。因此按 routing key 判断会让第二次投递立即停泊。

验证:go test -count=1 ./... 全绿
This commit is contained in:
2026-10-30 15:20:15 +08:00
parent 03d4301020
commit 49fc17c445
10 changed files with 290 additions and 369 deletions

View File

@@ -246,7 +246,7 @@ func SetRouter(db *gorm.DB, cache *rediscache.Client, rmq *rabbitmq.RabbitMQ) *g
queue := q
go rabbitmq.RunConsumer(context.Background(), rmq, "notification-"+queue, 10,
func(ch *amqp.Channel) error {
return worker.NewNotificationWorker(ch, db, queue, sseHub).Run(context.Background())
return worker.NewNotificationWorker(ch, rmq, db, queue, sseHub).Run(context.Background())
})
}
} else {