{"record":{"id":"219380542efa2d7c","repo":"apache/rocketmq","slug":"consumergroup-is-null","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/DefaultMQPullConsumerImpl.java","lineNumber":778,"sourceCode":"            case START_FAILED:\n            case SHUTDOWN_ALREADY:\n                throw new MQClientException(\"The PullConsumer service state not OK, maybe started once, \"\n                    + this.serviceState\n                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_SERVICE_NOT_OK),\n                    null);\n            default:\n                break;\n        }\n\n    }\n\n    private void checkConfig() throws MQClientException {\n        // check consumerGroup\n        Validators.checkGroup(this.defaultMQPullConsumer.getConsumerGroup());\n\n        // consumerGroup\n        if (null == this.defaultMQPullConsumer.getConsumerGroup()) {\n            throw new MQClientException(\n                \"consumerGroup is null\"\n                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),\n                null);\n        }\n\n        // consumerGroup\n        if (this.defaultMQPullConsumer.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        // messageModel\n        if (null == this.defaultMQPullConsumer.getMessageModel()) {\n            throw new MQClientException(","sourceCodeStart":760,"sourceCodeEnd":796,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java#L760-L796","documentation":"Thrown by checkConfig() during start() when the consumer group is null. Note Validators.checkGroup runs first and usually throws its own error for null; this explicit check exists as a belt-and-braces guard. The consumer group identifies the subscription and offset-tracking identity and must be set before start.","triggerScenarios":"Constructing DefaultMQPullConsumer with the no-arg constructor and never calling setConsumerGroup(...) before start(); passing null explicitly: new DefaultMQPullConsumer(null); a config property binding that silently leaves the group unset.","commonSituations":"Property placeholder not resolved (e.g. ${rocketmq.consumer.group} missing from environment), so the setter receives null; code copied from examples that assume a constructor argument that was removed.","solutions":["Set a non-null consumer group before start(): consumer.setConsumerGroup(\"my-group\")","Validate required config at application startup and fail fast with a clear message when the group property is missing","Prefer the parameterized constructor DefaultMQPullConsumer(consumerGroup) so the group cannot be forgotten"],"exampleFix":"// before\nDefaultMQPullConsumer consumer = new DefaultMQPullConsumer();\nconsumer.start(); // group still null\n\n// after\nDefaultMQPullConsumer consumer = new DefaultMQPullConsumer(\"my-consumer-group\");\nconsumer.setNamesrvAddr(namesrv);\nconsumer.start();","handlingStrategy":"validation","validationCode":"if (group == null || group.trim().isEmpty()) throw new IllegalStateException(\"consumer group must be configured\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the constructor that takes the group","Fail fast on unresolved config placeholders at startup"],"tags":["rocketmq","pull-consumer","config","consumer-group","startup"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}