pulsar-client-go icon indicating copy to clipboard operation
pulsar-client-go copied to clipboard

Close consumer message channel when consumer closed.

Open cocotyty opened this issue 5 years ago • 3 comments

Is your feature request related to a problem? Please describe.

lots of consumer code maybe like this:

for msg := range consumer.Chan(){
   // consume msg
}

if not close channel when consumer close, maybe cause goroutine leak.

Describe the solution you'd like

when close a consumer,close the consumer's message channel.

Describe alternatives you've considered

Additional context

cocotyty avatar Nov 10 '20 05:11 cocotyty

Hello, is this a bug or expected behaviour?

gonejack avatar Dec 30 '20 08:12 gonejack

Hello, I've also interested in this issue.

Currently it is impossible to detect if consumer closed if you are not using consumer.Receive() method. But this method is blocking and is intended to be used as a receiver of the message.

Maybe we can either add method like Closed() to the interface, or change Receive() method as proposed by issue author?

omnilight avatar Feb 24 '21 11:02 omnilight

Just met the same issue. This method would be more useful if you can close the channel.

isalb729 avatar Dec 23 '21 18:12 isalb729