正在显示
2 个修改的文件
包含
7 行增加
和
3 行删除
| @@ -3,6 +3,7 @@ package consumer | @@ -3,6 +3,7 @@ package consumer | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | "errors" | 5 | "errors" |
| 6 | + "time" | ||
| 6 | 7 | ||
| 7 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/port/consumer/configs" | 8 | "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/port/consumer/configs" |
| 8 | 9 | ||
| @@ -110,12 +111,15 @@ func (r *Runer) Start(ctx context.Context) { | @@ -110,12 +111,15 @@ func (r *Runer) Start(ctx context.Context) { | ||
| 110 | for { | 111 | for { |
| 111 | select { | 112 | select { |
| 112 | case <-ctx.Done(): | 113 | case <-ctx.Done(): |
| 113 | - r.consumerGroup.Close() | ||
| 114 | - logs.Warning("ctx cancel;consumerGroup.Close()") | 114 | + err := r.consumerGroup.Close() |
| 115 | + logs.Warning("ctx cancel;consumerGroup.Close();err:%s", err) | ||
| 115 | return | 116 | return |
| 116 | default: | 117 | default: |
| 117 | if err := r.consumerGroup.Consume(ctx, r.msgConsumer.topics, r.msgConsumer); err != nil { | 118 | if err := r.consumerGroup.Consume(ctx, r.msgConsumer.topics, r.msgConsumer); err != nil { |
| 118 | logs.Error("consumerGroup err:%s \n", err) | 119 | logs.Error("consumerGroup err:%s \n", err) |
| 120 | + //等待重试 | ||
| 121 | + timer := time.NewTimer(5 * time.Second) | ||
| 122 | + <-timer.C | ||
| 119 | } | 123 | } |
| 120 | r.msgConsumer.ready = make(chan struct{}) | 124 | r.msgConsumer.ready = make(chan struct{}) |
| 121 | } | 125 | } |
-
请 注册 或 登录 后发表评论