rocketmq方法
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
663 B

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(group string, resolver []string) {
p, err := rocketmq.NewProducer(
producer.WithGroupName(group),
producer.WithNsResolver(primitive.NewPassthroughResolver(resolver)),
//producer.WithCreateTopicKey("product"),
producer.WithRetry(1))
if err != nil {
log.Println("New "+group+" producer failed", err)
return
}
err = p.Start()
if err != nil {
log.Println(group+" producer start failed", err)
return
}
MqPool = p
}