{"record":{"id":"28ed7b6b6862a68f","repo":"alibaba/canal","slug":"start-rocketmq-producer-error","errorCode":null,"errorMessage":"Start RocketMQ producer error","messagePattern":"Start RocketMQ producer error","errorType":"exception","errorClass":"CanalException","httpStatus":null,"severity":"error","filePath":"connector/rocketmq-connector/src/main/java/com/alibaba/otter/canal/connector/rocketmq/producer/CanalRocketMQProducer.java","lineNumber":92,"sourceCode":"\n        defaultMQProducer = new DefaultMQProducer(rocketMQProperties.getProducerGroup(),\n            rpcHook,\n            rocketMQProperties.isEnableMessageTrace(),\n            rocketMQProperties.getCustomizedTraceTopic());\n        if (CLOUD_ACCESS_CHANNEL.equals(rocketMQProperties.getAccessChannel())) {\n            defaultMQProducer.setAccessChannel(AccessChannel.CLOUD);\n        }\n        if (!StringUtils.isEmpty(rocketMQProperties.getNamespace())) {\n            defaultMQProducer.setNamespace(rocketMQProperties.getNamespace());\n        }\n        defaultMQProducer.setNamesrvAddr(rocketMQProperties.getNamesrvAddr());\n        defaultMQProducer.setRetryTimesWhenSendFailed(rocketMQProperties.getRetryTimesWhenSendFailed());\n        defaultMQProducer.setVipChannelEnabled(rocketMQProperties.isVipChannelEnabled());\n        logger.info(\"##Start RocketMQ producer##\");\n        try {\n            defaultMQProducer.start();\n        } catch (MQClientException ex) {\n            throw new CanalException(\"Start RocketMQ producer error\", ex);\n        }\n\n        int parallelPartitionSendThreadSize = mqProperties.getParallelSendThreadSize();\n        sendPartitionExecutor = new ThreadPoolExecutor(parallelPartitionSendThreadSize,\n            parallelPartitionSendThreadSize,\n            0,\n            TimeUnit.SECONDS,\n            new ArrayBlockingQueue<>(parallelPartitionSendThreadSize * 2),\n            new NamedThreadFactory(\"MQ-Parallel-Sender-Partition\"),\n            new ThreadPoolExecutor.CallerRunsPolicy());\n    }\n\n    private void loadRocketMQProperties(Properties properties) {\n        RocketMQProducerConfig rocketMQProperties = (RocketMQProducerConfig) this.mqProperties;\n        // 兼容下<=1.1.4的mq配置\n        doMoreCompatibleConvert(\"canal.mq.servers\", \"rocketmq.namesrv.addr\", properties);\n        doMoreCompatibleConvert(\"canal.mq.producerGroup\", \"rocketmq.producer.group\", properties);\n        doMoreCompatibleConvert(\"canal.mq.namespace\", \"rocketmq.namespace\", properties);","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/connector/rocketmq-connector/src/main/java/com/alibaba/otter/canal/connector/rocketmq/producer/CanalRocketMQProducer.java#L74-L110","documentation":"Thrown by CanalRocketMQProducer.init when defaultMQProducer.start() raises an MQClientException. By this point the DefaultMQProducer is configured (nameserver, namespace, retry, vip channel); start() fails because the producer cannot register with a nameserver/broker — unreachable nameserver, invalid nameserver address, namespace/access-channel mismatch, or a client-side config error.","triggerScenarios":"defaultMQProducer.start() at line 90 throws MQClientException. Causes: rocketmq.namesrv.addr unreachable or malformed; nameserver returned no broker routing; AccessChannel.CLOUD set without valid cloud credentials/namespace; duplicate producer group already in use; vipChannelEnabled mismatch with the broker.","commonSituations":"Wrong/unreachable rocketmq.namesrv.addr; firewall blocking the nameserver or broker ports; Aliyun cloud access channel selected without credentials; producer group name collision with another running producer; broker cluster down during producer init.","solutions":["Verify rocketmq.namesrv.addr resolves and the nameserver port (9876) is reachable from the producer host.","Confirm the producer group name is unique and not used by another active producer instance.","If using AccessChannel.CLOUD (Aliyun), ensure namespace and cloud credentials are correctly set; otherwise leave access channel as LOCAL.","Retry start() after a short delay for transient nameserver/broker unavailability.","Inspect MQClientException.getMessage() — it typically names the exact failing step (e.g. 'No route info of this topic', 'name server error')."],"exampleFix":"// before\ntry {\n    defaultMQProducer.start();\n} catch (MQClientException ex) {\n    throw new CanalException(\"Start RocketMQ producer error\", ex);\n}\n\n// after — retry transient start failures, surface nameserver in error\nint attempts = 0;\nwhile (attempts++ < 3) {\n    try {\n        defaultMQProducer.start();\n        break;\n    } catch (MQClientException ex) {\n        if (attempts >= 3) throw new CanalException(\n            \"Start RocketMQ producer error [namesrv=\"\n            + rocketMQProperties.getNamesrvAddr() + \"]: \" + ex.getMessage(), ex);\n    }\n}","handlingStrategy":"retry","validationCode":"if (StringUtils.isEmpty(rocketMQProperties.getNamesrvAddr()))\n    throw new IllegalStateException(\"rocketmq namesrv addr missing\");","typeGuard":null,"tryCatchPattern":"int attempts = 0;\nwhile (attempts++ < 3) {\n    try {\n        defaultMQProducer.start();\n        break;\n    } catch (MQClientException ex) {\n        if (attempts >= 3)\n            throw new CanalException(\"Start RocketMQ producer error\", ex);\n    }\n}","preventionTips":["Verify rocketmq.namesrv.addr and the nameserver port (9876) are reachable.","Use a unique producer group name per producer instance.","For AccessChannel.CLOUD, ensure cloud namespace and credentials are set."],"tags":["rocketmq","producer","network","canal-connector","initialization"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}