liye-github opened a new issue #1924: client lib v2.0.0 (the pure go version), 
can't re-create client
URL: https://github.com/apache/rocketmq/issues/1924
 
 
   Within the same process, once a client is "Shutdown()", it is not able to 
create a same client again (same GroupName, NameServers, and InstanceName).
   
   Demo code: minor modification upon official example 
"examples/consumer/simple/main.go":
   
   ```go
   package main
   
   import (
           "context"
           "fmt"
           "os"
           "time"
   
           "github.com/apache/rocketmq-client-go/v2"
           "github.com/apache/rocketmq-client-go/v2/consumer"
           "github.com/apache/rocketmq-client-go/v2/primitive"
   )
   
   func sub(name string) {
           c, _ := rocketmq.NewPushConsumer(
                   consumer.WithGroupName("testGroup"),
                   consumer.WithNameServer([]string{"127.0.0.1:9876"}),
                   consumer.WithInstance(name),
           )
           err := c.Subscribe("test", consumer.MessageSelector{}, func(ctx 
context.Context,
                   msgs ...*primitive.MessageExt) (consumer.ConsumeResult, 
error) {
                   for i := range msgs {
                           fmt.Printf("subscribe callback: %v \n", msgs[i])
                   }
   
                   return consumer.ConsumeSuccess, nil
           })
           if err != nil {
                   fmt.Println(err.Error())
           }
           // Note: start after subscribe
           err = c.Start()
           if err != nil {
                   fmt.Println(err.Error())
                   os.Exit(-1)
           }
           // Shutdown after 10s
           time.Sleep(time.Second*10)
           err = c.Shutdown()
           if err != nil {
                   fmt.Printf("shutdown Consumer error: %s", err.Error())
           }
   }
   
   func main() {
           // this will run OK
           sub("name1")
           // this will fail
           sub("name1")
   }
   ```

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to