ZJRui commented on issue #3297:
URL: https://github.com/apache/rocketmq/issues/3297#issuecomment-907586957
> First of all, it is recommended to use the version later than 4.7.
> In version 4.7 and above, the clientId generation rules of consumer and
producer are the same, which can ensure that the same MQClientInstance is used
by default in the same process.
我看了下4.8.0的代码 ,好像并不是像你说的这样。
4.8.0的代码中 对于DefaultMQPullConsumerImpl的start方法中
会判断MessageModel如果为集群模式,则将instanceName改为Pid
` if (this.defaultMQPullConsumer.getMessageModel() ==
MessageModel.CLUSTERING) {
this.defaultMQPullConsumer.changeInstanceNameToPID();
}
`
但是在DefaultMQProducerImpl的start方法中
,只有当ProducerGroup为指定的group时才会将instanceName改为pid
` if
(!this.defaultMQProducer.getProducerGroup().equals(MixAll.CLIENT_INNER_PRODUCER_GROUP))
{
this.defaultMQProducer.changeInstanceNameToPID();
}`
也就是说这样会导致 Consumer和Producer的InstanceName
不同,从而构建的clientId不同,最终导致创建两个MQClientInstance对象。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]