Browse Source

🐛 close publisher properly to prevent resource leaks

pull/111/head
Tony An 3 years ago
parent
commit
c6486ad061
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      publish.go

+ 6
- 0
publish.go View File

@ -191,6 +191,12 @@ func (publisher *Publisher) Publish(
// The publisher should be discarded as it's not safe for re-use
// Only call Close() once
func (publisher *Publisher) Close() {
// close the channel so that rabbitmq server knows that the
// publisher has been stopped.
err := publisher.chanManager.Close()
if err != nil {
publisher.options.Logger.Warnf("error while closing the channel: %v", err)
}
publisher.options.Logger.Infof("closing publisher...")
go func() {
publisher.closeConnectionToManagerCh <- struct{}{}


Loading…
Cancel
Save