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.

30 lines
669 B

package rocketmq
import (
"encoding/json"
"github.com/apache/rocketmq-client-go/v2/primitive"
"log"
"testing"
// "tgo/helper"
"context"
)
func Test_Send(t *testing.T) {
MqConnect("ProductService", []string{"127.0.0.1:9876"})
log.Println("2", MqPool)
mq_data := map[string]interface{}{
"a": "a",
}
topic := "product"
tag := "collect_product"
msg_str, _ := json.Marshal(mq_data)
msg1 := primitive.NewMessage(topic, msg_str)
msg1.WithTag(tag)
res, err := SendSync(context.Background(), msg1)
if err != nil {
log.Printf("send tag sync message error:%s\n", err)
} else {
log.Printf("send tag sync message success. result=%s\n", res.String())
}
}