Browse Source

close channel once the consumer is stopped

Signed-off-by: Aaqa Ishtyaq <aaqa@hackerrank.com>
pull/95/head
Aaqa Ishtyaq 3 years ago
parent
commit
3589e5a6e5
No known key found for this signature in database GPG Key ID: C4BE1CE588EB9E21
1 changed files with 7 additions and 0 deletions
  1. +7
    -0
      consume.go

+ 7
- 0
consume.go View File

@ -108,6 +108,13 @@ func (consumer *Consumer) Close() {
consumer.isClosedMux.Lock() consumer.isClosedMux.Lock()
defer consumer.isClosedMux.Unlock() defer consumer.isClosedMux.Unlock()
consumer.isClosed = true 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...") consumer.options.Logger.Infof("closing consumer...")
go func() { go func() {
consumer.closeConnectionToManagerCh <- struct{}{} consumer.closeConnectionToManagerCh <- struct{}{}


Loading…
Cancel
Save