package rocketmq import ( "github.com/apache/rocketmq-client-go/v2" "github.com/apache/rocketmq-client-go/v2/primitive" "github.com/apache/rocketmq-client-go/v2/producer" "log" ) var MqPool *rocketmq.Producer func MqConnect() { MqPool, err := rocketmq.NewProducer( producer.WithGroupName("ProductService"), producer.WithNsResolver(primitive.NewPassthroughResolver([]string{"127.0.0.1:9876"})), //producer.WithCreateTopicKey("product"), producer.WithRetry(1)) if err != nil { log.Println("New ProductService producer failed", err) } err = MqPool.Start() if err != nil { log.Println("ProductService producer start failed", err) } }