Skip to content

Commit

Permalink
fix: unsubscribe channel if start the consumer
Browse files Browse the repository at this point in the history
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed Apr 25, 2022
1 parent 0cbfbd1 commit e0db124
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ func (w *Worker) Shutdown() error {
}

w.stopOnce.Do(func() {
_ = w.subscription.Unsubscribe()
// unsubscribe channel if start the consumer
if w.subscription != nil {
_ = w.subscription.Unsubscribe()
}

close(w.stop)
select {
case <-w.exit:
Expand Down

0 comments on commit e0db124

Please sign in to comment.