linkypi opened a new issue #2697:
URL: https://github.com/apache/rocketmq/issues/2697
rocketmq 4.8.0 单点部署在docker容器中,其中broker的配置文件中已配置brokerIP1 ,配置的是域名,而非实际IP地址:
```
brokerIP1=rmqbroker
```
如此配置就会导致问题的出现,若配置的是实际的IP则MQ消息状态正常。通过调试源码发现 rocketmq-tools
在判断消息是否已消费时未对域名进行解析导致。

修复后:

源码:
``` java
while (it.hasNext()) {
Entry<MessageQueue, OffsetWrapper> next = it.next();
MessageQueue mq = next.getKey();
if (mq.getTopic().equals(msg.getTopic()) && mq.getQueueId() ==
msg.getQueueId()) {
BrokerData brokerData =
ci.getBrokerAddrTable().get(mq.getBrokerName());
if (brokerData != null) {
final String msgStoreHost =
RemotingUtil.socketAddress2String(msg.getStoreHost());
final String brokerHost = getBrokerIpFromCluster(brokerData);
log.info("============= msgHostIp: {}, msg.getStoreHost(): {}
=============", msgStoreHost, brokerHost);
if (msgStoreHost.equals(brokerHost)) {
log.info("next.getValue().getConsumerOffset(): {},
msg.getQueueOffset(): {}",
next.getValue().getConsumerOffset(),
msg.getQueueOffset());
if (next.getValue().getConsumerOffset() >
msg.getQueueOffset()) {
return true;
}
}
}
}
}
private String getBrokerIpFromCluster(BrokerData brokerData ) throws
UnknownHostException {
String addr = brokerData.getBrokerAddrs().get(MixAll.MASTER_ID);
final String[] arr = addr.split(":");
final String host = arr[0];
final String brokerIp =
InetAddress.getAllByName(host)[0].getHostAddress() + ":" + arr[1];
return brokerIp;
}
```
希望尽早修复改问题。
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]