From 8324f872ef3a4d0c978a9b1d062800c6a1701c12 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 01 十二月 2023 09:58:17 +0800
Subject: [PATCH] fix

---
 pkg/nsqclient/consumer.go |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/pkg/nsqclient/consumer.go b/pkg/nsqclient/consumer.go
index 6e377b2..78908dc 100644
--- a/pkg/nsqclient/consumer.go
+++ b/pkg/nsqclient/consumer.go
@@ -90,9 +90,19 @@
 	for {
 		select {
 		case <-n.ctx.Done():
-			logx.Infof("[%s]%s stop consumer...", n.topic, n.channel)
+			logx.Infof("[%s] stop consumer...", n.topic)
+			for _, addr := range qAddr {
+				err = n.consumer.DisconnectFromNSQD(addr)
+				if err != nil {
+					logx.Errorf("disconnect from nsq server failed, err: %v, addr: %v, topic: %v", err, addr, n.topic)
+				} else {
+					logx.Infof("disconnect from nsq server success, addr: %v, topic: %v", addr, n.topic)
+				}
+			}
 			n.consumer.Stop()
-			logx.Infof("[%s]%s stop consumer success", n.topic, n.channel)
+			<-n.consumer.StopChan
+			logx.Infof("[%s] stop consumer success", n.topic)
+
 			return nil
 		}
 	}

--
Gitblit v1.8.0