12345678910111213141516171819202122232425262728293031323334353637 |
- package main
- import (
- "fmt"
- "go.mongodb.org/mongo-driver/bson"
- "jygit.jydev.jianyu360.cn/data_processing/common_utils/mongodb"
- "testing"
- "time"
- )
- func Test_NatsClient(t *testing.T) {
- mgo := mongodb.MongodbSim{
- MongodbAddr: "192.168.3.166:27082",
- DbName: "qfw",
- Size: 1,
- }
- mgo.InitPool()
- tmp, _ := mgo.FindById("bidding", "65578e020687916fae514d34", nil)
- msg := &MsgInfo{
- Id: "1", //消息唯一id
- CurrSetp: "test", //当前步骤
- Data: *tmp, //数据内容
- }
- msgByte, _ := bson.Marshal(msg)
- resp, err := Jnats.PubReqZip(Subscribe, msgByte, 10*time.Second)
- if err != nil {
- fmt.Println("发布回执异常:", err)
- return
- }
- respMsg := &MsgInfo{}
- if bson.Unmarshal(resp.Data, &respMsg) == nil {
- fmt.Println(respMsg.CurrSetp)
- fmt.Println(respMsg.Data["detail"])
- } else {
- fmt.Println("解析数据失败")
- }
- }
|