rocketmq-client-go icon indicating copy to clipboard operation
rocketmq-client-go copied to clipboard

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

Open HubQin opened this issue 1 year ago • 2 comments

The issue tracker is ONLY used for the go client (feature request of RocketMQ need to follow RIP process). 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. 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)
        1. 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.

  1. 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)
  2. 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)

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.

  3. 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?

  4. 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: sub-task1 description here,
    • sub-task2-issue-number: sub-task2 description here,
    • ...

HubQin avatar May 08 '23 02:05 HubQin

it seems a bug here, can you fix it ?

francisoliverlee avatar May 22 '23 02:05 francisoliverlee

@francisoliverlee Is the bug still here? If so, I think I could give it a try.

YarBor avatar Nov 30 '23 08:11 YarBor