apache/rocketmq · error · MQClientException
Can not find Message Queue for this topic, ${topic} Namesrv
Error message
Can not find Message Queue for this topic, ${topic} Namesrv return empty What it means
In fetchSubscribeMessageQueues, the name server returned a non-null TopicRouteData but topicRouteData2TopicSubscribeInfo produced an EMPTY queue set — the route is known yet yields no subscribable queues (queues are filtered out, typically because broker perms exclude read or the route lacks queue metadata). The client throws rather than return an empty set, because subscribing to nothing would silently consume no messages.
Source
Thrown at client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java:177
public List<MessageQueue> parsePublishMessageQueues(List<MessageQueue> messageQueueList) {
List<MessageQueue> resultQueues = new ArrayList<>();
for (MessageQueue queue : messageQueueList) {
String userTopic = NamespaceUtil.withoutNamespace(queue.getTopic(), this.mQClientFactory.getClientConfig().getNamespace());
resultQueues.add(new MessageQueue(userTopic, queue.getBrokerName(), queue.getQueueId()));
}
return resultQueues;
}
public Set<MessageQueue> fetchSubscribeMessageQueues(String topic) throws MQClientException {
try {
TopicRouteData topicRouteData = this.mQClientFactory.getMQClientAPIImpl().getTopicRouteInfoFromNameServer(topic, timeoutMillis);
if (topicRouteData != null) {
Set<MessageQueue> mqList = MQClientInstance.topicRouteData2TopicSubscribeInfo(topic, topicRouteData);
if (!mqList.isEmpty()) {
return mqList;
} else {
throw new MQClientException("Can not find Message Queue for this topic, " + topic + " Namesrv return empty", null);
}
}
} catch (Exception e) {
throw new MQClientException(
"Can not find Message Queue for this topic, " + topic + FAQUrl.suggestTodo(FAQUrl.MQLIST_NOT_EXIST),
e);
}
throw new MQClientException("Unknown why, Can not find Message Queue for this topic, " + topic, null);
}
public long searchOffset(MessageQueue mq, long timestamp) throws MQClientException {
// default return lower boundary offset when there are more than one offsets.
return searchOffset(mq, timestamp, BoundaryType.LOWER);
}
public long searchOffset(MessageQueue mq, long timestamp, BoundaryType boundaryType) throws MQClientException {
String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(this.mQClientFactory.getBrokerNameFromMessageQueue(mq));View on GitHub (pinned to 293f588571)
Solutions
- Run mqadmin topicRoute -t <topic> -n <namesrv> and confirm each broker has read queues (perm includes 2)
- Fix perms to 6 (rw) or recreate the topic on the intended brokers
- If namespaces are configured, confirm the topic string includes/applies the namespace consistently
Defensive patterns
Strategy: validation
Validate before calling
TopicRouteData route = /* raw route fetch */;
boolean readable = route != null && route.getQueueDatas().stream()
.anyMatch(qd -> org.apache.rocketmq.common.protocol.body.PermName.isReadable(qd.getPerm())
&& qd.getReadQueueNums() > 0);
if (!readable) throw new IllegalStateException("no readable queues for " + topic); Try / catch
try {
consumer.fetchSubscribeMessageQueues(topic);
} catch (MQClientException e) {
if (e.getMessage().contains("Namesrv return empty")) {
// route exists but yields no readable queues: fix perms / recreate topic
}
} Prevention
- Create topics with read perm for consumers (perm 6)
- Apply namespaces consistently between producer and consumer configs
When it happens
Trigger: Calling defaultMQPushConsumer/fetchSubscribeMessageQueues(topic) (or APIs that seed subscription from route) for a topic whose route yields no readable queues.
Common situations: Topic with write-only/read-only perms set opposite to the consumer's need; topic route propagation incomplete right after creation; consumer in a namespace mangling the topic name so the resolved route differs.
Related errors
- Can not find Message Queue for this topic, ${topic} See http
- add subscription exception
- The broker[${brokerName}] not exist
- Not found broker, maybe key is wrong
- Can not find Message Queue for this topic, ${topic}
AI-assisted analysis of apache/rocketmq@293f588571 (2026-08-14).
Data as JSON: /api/errors/342f72514f5a4e63.
Report an issue: GitHub.