Skip to content

Commit

Permalink
Merge 3ede545 into bb34171
Browse files Browse the repository at this point in the history
  • Loading branch information
guyinyou committed Aug 2, 2021
2 parents bb34171 + 3ede545 commit 424ac96
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Expand Up @@ -713,15 +713,25 @@ private TopicPublishInfo tryToFindTopicPublishInfo(final String topic) {
TopicPublishInfo topicPublishInfo = this.topicPublishInfoTable.get(topic);
if (null == topicPublishInfo || !topicPublishInfo.ok()) {
this.topicPublishInfoTable.putIfAbsent(topic, new TopicPublishInfo());
this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic);
topicPublishInfo = this.topicPublishInfoTable.get(topic);
if (!topicPublishInfo.checkNotFoundFlag()) {
this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic);
topicPublishInfo = this.topicPublishInfoTable.get(topic);
}
}

if (topicPublishInfo.isHaveTopicRouterInfo() || topicPublishInfo.ok()) {
return topicPublishInfo;
} else {
this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic, true, this.defaultMQProducer);
topicPublishInfo = this.topicPublishInfoTable.get(topic);
boolean found;
if (!topicPublishInfo.checkNotFoundFlag()) {
found = this.mQClientFactory.updateTopicRouteInfoFromNameServer(topic, true, this.defaultMQProducer);
topicPublishInfo = this.topicPublishInfoTable.get(topic);
if (!found) {
topicPublishInfo.setNotFoundFlag();
this.topicPublishInfoTable.get(defaultMQProducer.getCreateTopicKey()).setNotFoundFlag();
}
}
return topicPublishInfo;
}
}
Expand Down
Expand Up @@ -29,6 +29,15 @@ public class TopicPublishInfo {
private List<MessageQueue> messageQueueList = new ArrayList<MessageQueue>();
private volatile ThreadLocalIndex sendWhichQueue = new ThreadLocalIndex();
private TopicRouteData topicRouteData;
private long notFoundFlag = -1;

public void setNotFoundFlag() {
if (!checkNotFoundFlag()) {
notFoundFlag = System.currentTimeMillis();
}
}

public boolean checkNotFoundFlag() { return System.currentTimeMillis() < notFoundFlag + 2000; }

public boolean isOrderTopic() {
return orderTopic;
Expand Down

0 comments on commit 424ac96

Please sign in to comment.