fananchong opened a new issue #507:
URL: https://github.com/apache/rocketmq-client-go/issues/507


   My code is :
   
   ```go
   package main
   
   import (
        "context"
        "fmt"
        "log"
        "os"
        "strconv"
   
        "github.com/apache/rocketmq-client-go/v2"
        "github.com/apache/rocketmq-client-go/v2/primitive"
        "github.com/apache/rocketmq-client-go/v2/producer"
        "github.com/apache/rocketmq-client-go/v2/rlog"
   )
   
   func testNewAndClose() {
   
        rlog.SetLogLevel("error")
   
        p, _ := rocketmq.NewProducer(
                
producer.WithNsResovler(primitive.NewPassthroughResolver([]string{"127.0.0.1:9876"})),
                producer.WithRetry(2),
        )
        err := p.Start()
        if err != nil {
                fmt.Printf("start producer error: %s", err.Error())
                os.Exit(1)
        }
        topic := "test5"
   
        for i := 0; i < 1; i++ {
                msg := &primitive.Message{
                        Topic: topic,
                        Body:  []byte("Hello RocketMQ Go Client! " + 
strconv.Itoa(i)),
                }
                _, err := p.SendSync(context.Background(), msg)
   
                if err != nil {
                        fmt.Printf("send message error: %s\n", err)
                } else {
                        fmt.Printf("send message success\n")
                }
        }
        err = p.Shutdown()
        if err != nil {
                fmt.Printf("shutdown producer error: %s", err.Error())
        }
   }
   
   // Package main implements a simple producer to send message.
   func main() {
        testNewAndClose()
        log.Printf("try again ...")
        testNewAndClose()
   }
   ```
   
   and output is:
   
   ```vim
   fananchong@localhost:~/rocketmq-client-go/examples/producer/simple$ ./simple 
   send message success
   2020/07/06 10:36:34 try again ...
   send message error: service close is not running, please check
   ```
   
   The second instantiated object does not work.
   
   
   
   


----------------------------------------------------------------
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]


Reply via email to