apache / apache/rocketmq-client-go

Can not receive content in body field of response when using rpc request

Open
#1,046 2 comments 0 reactions 0 assignees View on GitHub
bug good first issue
Dominant language
Go
Stars
1.4k
Forks
445
PR merge metrics
No merged PRs in 30d

Description

The issue tracker is **ONLY** used for the go client (feature request of RocketMQ need to follow [RIP process](https://github.com/apache/rocketmq/wiki/RocketMQ-Improvement-Proposal)). Keep in mind, please check whether there is an existing same report before your raise a new one.

Alternately (especially if your communication is not a bug report), you can send mail to our [mailing lists](http://rocketmq.apache.org/about/contact/). We welcome any friendly suggestions, bug fixes, collaboration, and other improvements.

Please ensure that your bug report is clear and that it is complete. Otherwise, we may be unable to understand it or to reproduce it, either of which would prevent us from fixing the bug. We strongly recommend the report(bug report or feature request) could include some hints as to the following:

**BUG REPORT**
1. Please describe the issue you observed:

- What did you do (The steps to reproduce)?
- 1) run rpc consumer in example : https://github.com/apache/rocketmq-client-go/blob/master/examples/consumer/rpc/main.go (notice: topic name should created in advance)
- 2) run rpc producer to send request and get response in : https://github.com/apache/rocketmq-client-go/blob/master/examples/producer/rpc/sync/main.go

- What did you expect to see?
- should receive response content in body filed, which sending from consumer

- What did you see instead?
- Actually I get response like

```
Requst to RequestTopic cost:1042 ms responseMsg:[topic=DefaultCluster_REPLY_TOPIC, body=, Flag=0, properties=map[ARRIVE_TIME:1683511951236 CORRELATION_ID:82c36ba6-a75d-40d1-854b-1736ffd5ab26 MSG_TYPE:reply PUSH_REPLY_TIME:1683511945913 REPLY_TO_CLIENT:192.168.59.170@9552 TTL:5 UNIQ_KEY:C0A83BAA240C00000000263d4a980002], TransactionId=]

```
notice **body=**, content is empty.

2. Please tell us about your environment:

- What is your OS?
- windows 10

- What is your client version?
- run client in windows10 , rocketmq-client-go version: github.com/apache/rocketmq-client-go/v2 v2.1.2-0.20230412142645-25003f6f083d

- What is your RocketMQ version?
- namesrv and broker in docker (rocketmq:4.7.0-alpine)

3. Other information (e.g. detailed explanation, logs, related issues, suggestions on how to fix, etc):

in `CreateReplyMessage` method: (in file: rocketmq-client-go/consumer/message_util.go)
```golang
func CreateReplyMessage(requestMessage *primitive.MessageExt, body []byte) (*primitive.Message, error) {
if requestMessage == nil {
return nil, errors.New("create reply message fail, requestMessage cannot be null")
}

cluster := requestMessage.GetProperty(primitive.PropertyCluster)
replyTo := requestMessage.GetProperty(primitive.PropertyMessageReplyToClient)
correlationId := requestMessage.GetProperty(primitive.PropertyCorrelationID)
ttl := requestMessage.GetProperty(primitive.PropertyMessageTTL)

if cluster == "" {
return nil, fmt.Errorf("create reply message fail, requestMessage error, property[\"%s\"] is null", cluster)
}

var replayMessage primitive.Message

replayMessage.UnmarshalProperties(body)
replayMessage.Topic = internal.GetReplyTopic(cluster)
replayMessage.WithProperty(primitive.PropertyMsgType, internal.ReplyMessageFlag)
replayMessage.WithProperty(primitive.PropertyCorrelationID, correlationId)
replayMessage.WithProperty(primitive.PropertyMessageReplyToClient, replyTo)
replayMessage.WithProperty(primitive.PropertyMessageTTL, ttl)

return &replayMessage, nil
}
```
there is a line : `replayMessage.UnmarshalProperties(body)`, I feel confuse, why unmarshal body here?

**FEATURE REQUEST**

1. Please describe the feature you are requesting.

2. Provide any additional detail on your proposed use case for this feature.

2. Indicate the importance of this issue to you (blocker, must-have, should-have, nice-to-have). Are you currently using any workarounds to address this issue?

5. If there are some sub-tasks using -[] for each subtask and create a corresponding issue to map to the sub task:

- [sub-task1-issue-number](example_sub_issue1_link_here): sub-task1 description here,
- [sub-task2-issue-number](example_sub_issue2_link_here): sub-task2 description here,
- ...

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.