Skip to content

Commit 1117ab8

Browse files
authored
[ISSUE #9780] Skip unnecessary RPC when topic has no message queues (#9781)
1 parent b5da00a commit 1117ab8

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,21 +286,19 @@ private boolean rebalanceByTopic(final String topic, final boolean isOrder) {
286286
}
287287
case CLUSTERING: {
288288
Set<MessageQueue> mqSet = this.topicSubscribeInfoTable.get(topic);
289-
List<String> cidAll = this.mQClientFactory.findConsumerIdList(topic, consumerGroup);
290-
if (null == mqSet) {
289+
if (null == mqSet || mqSet.isEmpty()) {
291290
if (!topic.startsWith(MixAll.RETRY_GROUP_TOPIC_PREFIX)) {
292291
this.messageQueueChanged(topic, Collections.<MessageQueue>emptySet(), Collections.<MessageQueue>emptySet());
293292
log.warn("doRebalance, {}, but the topic[{}] not exist.", consumerGroup, topic);
294293
}
294+
break;
295295
}
296296

297-
if (null == cidAll) {
297+
List<String> cidAll = this.mQClientFactory.findConsumerIdList(topic, consumerGroup);
298+
if (null == cidAll || cidAll.isEmpty()) {
298299
log.warn("doRebalance, {} {}, get consumer id list failed", consumerGroup, topic);
299-
}
300-
301-
if (mqSet != null && cidAll != null) {
302-
List<MessageQueue> mqAll = new ArrayList<>();
303-
mqAll.addAll(mqSet);
300+
} else {
301+
List<MessageQueue> mqAll = new ArrayList<>(mqSet);
304302

305303
Collections.sort(mqAll);
306304
Collections.sort(cidAll);

0 commit comments

Comments
 (0)