JCQ 2022-04-06

This commit is contained in:
807875765@qq.com
2022-04-06 16:03:29 +08:00
parent 72c0c58e2d
commit 583c9210b5
4 changed files with 80 additions and 2 deletions

View File

@@ -16,8 +16,9 @@ import (
)
const (
sigKey = "signature"
httpURL = "http://jcq-hb-yd-001-httpsrv-nlb-FI.jvessel-open-hb.jdcloud.com:8080"
sigKey = "signature"
httpURL = "http://jcq-hb-yd-001-httpsrv-nlb-FI.jvessel-open-hb.jdcloud.com:8080"
httpURL2 = "http://114.67.73.174:8080/msg"
ConsumerGroupID = "open_message_573819178445" //所有topic都是这个
ConsumerGroupID2 = "open_message_413277234485" //所有topic都是这个
@@ -146,3 +147,16 @@ func (a *API) ConsumeInfo(topic, consumerGroupId string, size int) (consumeInfoR
}
return consumeInfoResult, err
}
func (a *API) ConsumeInfo2(topic, consumerGroupId string, size int) (consumeInfoResult []*ConsumeInfoResult, err error) {
result, err := a.AccessAPI("v2/messages", httpURL2, map[string]interface{}{
"topic": topic,
"consumerGroupId": consumerGroupId,
"size": size,
//"ack": "true", //默认消费之后就确认
})
if err == nil {
utils.Map2StructByJson(result["result"].(map[string]interface{})["messages"], &consumeInfoResult, false)
}
return consumeInfoResult, err
}

View File

@@ -25,3 +25,11 @@ func init() {
func TestConsumeInfo(t *testing.T) {
fmt.Println(utils.Str2Float64("2.60"))
}
func TestAPI_ConsumeInfo2(t *testing.T) {
result, _ := api.ConsumeInfo2("open_message_pop_order_create_E1D746D42474D5F1F1A10CECE75D99F6", "open_message_573819178445", 32)
for _, val := range result {
fmt.Println("")
fmt.Println(val.MessageBody)
}
}