{"record":{"id":"064c40d4337883ec","repo":"apache/rocketmq","slug":"create-new-topic-failed","errorCode":null,"errorMessage":"create new topic failed","messagePattern":"create new topic failed","errorType":"exception","errorClass":"MQClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java","lineNumber":139,"sourceCode":"                        }\n\n                        if (createOK) {\n                            orderTopicString.append(brokerData.getBrokerName());\n                            orderTopicString.append(\":\");\n                            orderTopicString.append(queueNum);\n                            orderTopicString.append(\";\");\n                        }\n                    }\n                }\n\n                if (exception != null && !createOKAtLeastOnce) {\n                    throw exception;\n                }\n            } 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    }","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java#L121-L157","documentation":"The outer catch of MQAdminImpl.createTopic wraps any exception thrown during topic creation (including the inner 'Not found broker' error, remoting failures, or broker rejection) into MQClientException('create new topic failed'). The original cause is preserved in the exception chain, so e.getCause() holds the real failure.","triggerScenarios":"Any client-side createTopic call that fails: no broker found for the key, name server timeout, broker returns an error for the create request, or insufficient permissions (TOPIC creation disabled, autoCreateTopicEnable=false).","commonSituations":"Auto-create disabled on brokers and the key/broker mapping wrong; network partition to name server; using a non-admin client without topic-creation permission.","solutions":["Inspect e.getCause() — it distinguishes 'not found broker' vs timeout vs broker-side rejection","Prefer mqadmin updateTopic -n <namesrv> -b <brokerAddr> -t <topic> for creation","Verify autoCreateTopicEnable or explicit create permission on the cluster","Confirm name server connectivity and topic config (queue counts, perms) are valid"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    mqAdmin.createTopic(key, topic, numQueues);\n} catch (MQClientException e) {\n    Throwable cause = e.getCause();\n    log.error(\"createTopic failed: {}\", cause == null ? e : cause);\n    // branch on cause: not-found-broker vs timeout vs permission\n}","preventionTips":["Always inspect the cause chain of this wrapper","Pre-create topics out-of-band with mqadmin rather than at app runtime"],"tags":["topic","admin","wrapper-exception","broker"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}