|
|
- 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())
- }
-
- }
|