{"record":{"id":"f1b811eba6e608d0","repo":"apache/rocketmq","slug":"can-not-find-message-queue-for-this-topic-topic","errorCode":null,"errorMessage":"Can not find Message Queue for this topic, ${topic}","messagePattern":"Can not find Message Queue for this topic, (.+?)","errorType":"exception","errorClass":"MQClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java","lineNumber":153,"sourceCode":"            } else {\n                throw new MQClientException(\"Not found broker, maybe key is wrong\", null);\n            }\n        } catch (Exception e) {\n            throw new MQClientException(\"create new topic failed\", e);\n        }\n    }\n\n    public List<MessageQueue> fetchPublishMessageQueues(String topic) throws MQClientException {\n        try {\n            TopicRouteData topicRouteData = this.mQClientFactory.getMQClientAPIImpl().getTopicRouteInfoFromNameServer(topic, timeoutMillis);\n            if (topicRouteData != null) {\n                TopicPublishInfo topicPublishInfo = MQClientInstance.topicRouteData2TopicPublishInfo(topic, topicRouteData);\n                if (topicPublishInfo != null && topicPublishInfo.ok()) {\n                    return parsePublishMessageQueues(topicPublishInfo.getMessageQueueList());\n                }\n            }\n        } catch (Exception e) {\n            throw new MQClientException(\"Can not find Message Queue for this topic, \" + topic, e);\n        }\n\n        throw new MQClientException(\"Unknown why, Can not find Message Queue for this topic, \" + topic, null);\n    }\n\n    public List<MessageQueue> parsePublishMessageQueues(List<MessageQueue> messageQueueList) {\n        List<MessageQueue> resultQueues = new ArrayList<>();\n        for (MessageQueue queue : messageQueueList) {\n            String userTopic = NamespaceUtil.withoutNamespace(queue.getTopic(), this.mQClientFactory.getClientConfig().getNamespace());\n            resultQueues.add(new MessageQueue(userTopic, queue.getBrokerName(), queue.getQueueId()));\n        }\n\n        return resultQueues;\n    }\n\n    public Set<MessageQueue> fetchSubscribeMessageQueues(String topic) throws MQClientException {\n        try {\n            TopicRouteData topicRouteData = this.mQClientFactory.getMQClientAPIImpl().getTopicRouteInfoFromNameServer(topic, timeoutMillis);","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java#L135-L171","documentation":"In MQAdminImpl.fetchPublishMessageQueues, any exception while fetching the topic route from the name server (timeout, remoting error, topic-not-found response) is rethrown as MQClientException('Can not find Message Queue for this topic, <topic>') with the original cause attached. It fires only when the route lookup itself throws — not when the route is merely empty.","triggerScenarios":"Calling defaultMQProducer.fetchPublishMessageQueues(topic)/mqAdmin.fetchPublishMessageQueues(topic) when getTopicRouteInfoFromNameServer throws — e.g. TOPIC_NOT_EXIST response, name server unreachable, or timeout.","commonSituations":"Fetching queues before the topic exists; wrong name server address in client config; name server briefly down during deploy.","solutions":["Verify the topic exists: mqadmin topicStatus -n <namesrv> -t <topic>, create it if missing","Check name server address and connectivity from the client host","Retry with backoff if the failure was a transient timeout"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    List<MessageQueue> q = producer.fetchPublishMessageQueues(topic);\n} catch (MQClientException e) {\n    // cause distinguishes TOPIC_NOT_EXIST vs timeout; create topic or retry\n}","preventionTips":["Ensure topics exist before app startup (IaC or mqadmin bootstrap)","Verify NAMESRV_ADDR as part of deployment checks"],"tags":["topic","admin","routing","nameserver"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}