package nats import ( "git.aionnect.com/aionnect/go-common/utils/date" "git.aionnect.com/aionnect/go-common/utils/mq" "git.aionnect.com/aionnect/go-common/utils/mq/topic" "testing" ) func TestProducer_SendJSON(t *testing.T) { producer := NewProducer() defer func(producer *Producer) { _ = producer.Close() }(producer) msg := &mq.TestMsg{Message: "你好, 世界!", Time: date.Now()} tpc := topic.TOP("test-subject") for i := 0; i < 5; i++ { result, err := producer.SendJSON(tpc, msg) if err != nil { t.Error("Failed to produce message: ", err) } t.Logf(result.(string)) } }