{"record":{"id":"a0cc52da29e975ac","repo":"apache/rocketmq","slug":"consumergroup-is-null-a0cc52","errorCode":null,"errorMessage":"consumerGroup is null","messagePattern":"consumerGroup is null","errorType":"validation","errorClass":"MQClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java","lineNumber":1029,"sourceCode":"\n        try {\n            this.updateTopicSubscribeInfoWhenSubscriptionChanged();\n            this.mQClientFactory.checkClientInBroker();\n            if (this.mQClientFactory.sendHeartbeatToAllBrokerWithLock()) {\n                this.mQClientFactory.rebalanceImmediately();\n            }\n        } catch (Exception e) {\n            log.warn(\"Start the consumer {} fail.\", this.defaultMQPushConsumer.getConsumerGroup(), e);\n            shutdown();\n            throw e;\n        }\n    }\n\n    private void checkConfig() throws MQClientException {\n        Validators.checkGroup(this.defaultMQPushConsumer.getConsumerGroup());\n\n        if (null == this.defaultMQPushConsumer.getConsumerGroup()) {\n            throw new MQClientException(\n                \"consumerGroup is null\"\n                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),\n                null);\n        }\n\n        if (this.defaultMQPushConsumer.getConsumerGroup().equals(MixAll.DEFAULT_CONSUMER_GROUP)) {\n            throw new MQClientException(\n                \"consumerGroup can not equal \"\n                    + MixAll.DEFAULT_CONSUMER_GROUP\n                    + \", please specify another one.\"\n                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),\n                null);\n        }\n\n        if (null == this.defaultMQPushConsumer.getMessageModel()) {\n            throw new MQClientException(\n                \"messageModel is null\"\n                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),","sourceCodeStart":1011,"sourceCodeEnd":1047,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java#L1011-L1047","documentation":"checkConfig() runs at the start of consumer startup and validates the consumer group. This branch fires when getConsumerGroup() returns null. In practice Validators.checkGroup just above usually rejects null/blank groups first with its own message, so seeing this exact message means validation reached the explicit null check.","triggerScenarios":"Constructing DefaultMQPushConsumer with a null group and calling start(); a setter or DI framework injecting null (missing property placeholder) so consumerGroup stays null; calling setConsumerGroup(null) before start.","commonSituations":"Property placeholder not resolved (@Value('${mq.group}') missing from config); creating the consumer with the no-arg constructor and forgetting setConsumerGroup; passing a null variable from dynamic per-tenant configuration.","solutions":["Set a non-null consumer group before start(): constructor DefaultMQPushConsumer(\"my-group\") or setConsumerGroup(...)","If the group comes from config, validate the property is present at boot (fail fast on missing placeholder)","Disallow null in your own consumer-factory code with a precondition check"],"exampleFix":"// before\nDefaultMQPushConsumer c = new DefaultMQPushConsumer(); // no group set\nc.start(); // consumerGroup is null\n\n// after\nDefaultMQPushConsumer c = new DefaultMQPushConsumer(\"order-consumer-group\");\nc.start();","handlingStrategy":"validation","validationCode":"if (consumerGroup == null || consumerGroup.trim().isEmpty())\n    throw new IllegalArgumentException(\"consumerGroup must be set\");\nDefaultMQPushConsumer c = new DefaultMQPushConsumer(consumerGroup);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fail fast on missing consumer-group config at application boot","Fail config startup when property placeholders are unresolved instead of injecting null","Centralize consumer construction so group is always passed via constructor"],"tags":["rocketmq","config","consumer-group","validation"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}