You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/01/29 15:30:22 UTC

[GitHub] [pulsar-client-go] wuYin opened a new pull request #457: Fix unsubscribe blocked when consumer is closing or has closed

wuYin opened a new pull request #457:
URL: https://github.com/apache/pulsar-client-go/pull/457


   ### Motivation
   
   For the present consumer, `Close()` and `Unsubscribe()` handled by the same eventloop goroutine.
   The eventloop exited after `Close()`, then unsubscribe event wouldn't be selected and handled anymore.
   
   example:
   ```go
   func main() {
   	client, err := pulsar.NewClient(pulsar.ClientOptions{URL: "pulsar://localhost:6650"})
   	if err != nil {
   		log.Fatal(err)
   	}
   	defer client.Close()
   
   	consumer, err := client.Subscribe(pulsar.ConsumerOptions{
   		Topic:            "topic-1",
   		SubscriptionName: "my-sub",
   	})
   	if err != nil {
   		log.Fatal(err)
   	}
   	// blocked send event to eventloop channel since it never be selected anymore
   	defer consumer.Unsubscribe() // unintentional
   	defer consumer.Close()
   }
   ```
   
   `Unsubscribe()` blocked:
   
   ![image](https://user-images.githubusercontent.com/24536920/106294060-ab5d6b80-6289-11eb-913c-85e1d18467a0.png)
   
   
   
   
   ### Modifications
   
   Check consumer state before send unsubscribe event, if consumer is closing or has closed, just logging it
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar-client-go] wolfstudy merged pull request #457: Fix unsubscribe blocked when consumer is closing or has closed

Posted by GitBox <gi...@apache.org>.
wolfstudy merged pull request #457:
URL: https://github.com/apache/pulsar-client-go/pull/457


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org