From 3589e5a6e59424e0959c176ca1731ba510a7181a Mon Sep 17 00:00:00 2001 From: Aaqa Ishtyaq Date: Fri, 2 Dec 2022 13:52:36 +0530 Subject: [PATCH] close channel once the consumer is stopped Signed-off-by: Aaqa Ishtyaq --- consume.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/consume.go b/consume.go index 30c9a64..a627923 100644 --- a/consume.go +++ b/consume.go @@ -108,6 +108,13 @@ func (consumer *Consumer) Close() { consumer.isClosedMux.Lock() defer consumer.isClosedMux.Unlock() consumer.isClosed = true + // close the channel so that rabbitmq server knows that the + // consumer has been stopped. + err := consumer.chanManager.Close() + if err != nil { + consumer.options.Logger.Warnf("error while closing the channel: %v", err) + } + consumer.options.Logger.Infof("closing consumer...") go func() { consumer.closeConnectionToManagerCh <- struct{}{}