caigy commented on a change in pull request #3208:
URL: https://github.com/apache/rocketmq/pull/3208#discussion_r680901156
##########
File path:
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
##########
@@ -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);
Review comment:
I think it can use the return value of `putIfAbsent()` here
##########
File path:
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
##########
@@ -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;
Review comment:
Move this declaration into 'if' block.
##########
File path:
client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
##########
@@ -29,6 +29,15 @@
private List<MessageQueue> messageQueueList = new
ArrayList<MessageQueue>();
private volatile ThreadLocalIndex sendWhichQueue = new ThreadLocalIndex();
private TopicRouteData topicRouteData;
+ private long notFoundFlag = -1;
Review comment:
Is it more appropriate to name it as `lastNotFoundTimestamp`?
##########
File path:
client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
##########
@@ -29,6 +29,15 @@
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; }
Review comment:
Define `2000` as a constant
--
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]