apache / apache/rocketmq-client-go
use rocketmq-go-client send msg with Compress==true caught search msg return NullPointErr Exception by origin tool
- Dominant language
- Go
- Stars
- 1.4k
- Forks
- 445
- PR merge metrics
- No merged PRs in 30d
Description
SDK version: github.com/apache/rocketmq-client-go/v2
my test code:
```
for i := 0; i < userconf.MsgNum; i++ {
t := time.Now().Format("2006-01-02 15:04:05")
msg := &primitive.Message{
Topic: topic,
Body: []byte("RocketMQ Go Client Message: " + strconv.Itoa(i) + " sending time:" + t),
}
msg.Compress =true
res, err := p.SendSync(context.Background(), msg)
if err != nil {
fmt.Printf("batch send producer_sync message error:%s\n", err)
} else {
fmt.Printf("batch send producer_sync message success. result=%s,msg=%s\n", res.String(),
string(msg.Body))
}
```
when I send msg ,sdk didn't return any error ; buy when I use mqadmin query msg by MsgID, it return NullPointErr Exception ;
I check the sdk code, found that in rocketmq-client-go/v2/producer/producer.go:
```
func (p *defaultProducer) tryCompressMsg(msg *primitive.Message) bool {
if msg.Compress {
return true
}
if msg.Batch {
return false
}
if len(msg.Body) < p.options.CompressMsgBodyOverHowmuch {
return false
}
compressedBody, e := utils.Compress(msg.Body, p.options.CompressLevel)
if e != nil {
return false
}
msg.CompressedBody = compressedBody
msg.Compress = true
return true
}
```
when msg.Compress == true ,it just returns, BUT msg.CompressedBody IS NULL THIS MOUMEMT ! IS THIS THE PROBLEM ?
Contributor guide
Assessment
This issue has not been assessed yet.