{"record":{"id":"822ebd0f33e8e3c6","repo":"apache/rocketmq","slug":"messagemodel-is-null-822ebd","errorCode":null,"errorMessage":"messageModel is null","messagePattern":"messageModel is null","errorType":"validation","errorClass":"MQClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java","lineNumber":796,"sourceCode":"            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(\n                \"messageModel is null\"\n                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),\n                null);\n        }\n\n        // allocateMessageQueueStrategy\n        if (null == this.defaultMQPullConsumer.getAllocateMessageQueueStrategy()) {\n            throw new MQClientException(\n                \"allocateMessageQueueStrategy is null\"\n                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),\n                null);\n        }\n\n        // allocateMessageQueueStrategy\n        if (this.defaultMQPullConsumer.getConsumerTimeoutMillisWhenSuspend() < this.defaultMQPullConsumer.getBrokerSuspendMaxTimeMillis()) {\n            throw new MQClientException(\n                \"Long polling mode, the consumer consumerTimeoutMillisWhenSuspend must greater than brokerSuspendMaxTimeMillis\"\n                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),","sourceCodeStart":778,"sourceCodeEnd":814,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java#L778-L814","documentation":"Thrown by checkConfig() during start() when messageModel is null. The message model (CLUSTERING vs BROADCASTING) determines how queues are allocated and offsets are stored; the implementation requires it to be explicitly present at start time.","triggerScenarios":"setMessageModel(null) before start(); a reflection/config binder that sets the field to null when the property string is empty; deserializing consumer config where the enum failed to parse.","commonSituations":"Note DefaultMQPullConsumer normally defaults messageModel to MessageModel.CLUSTERING in its field initializer, so hitting this usually means code explicitly nulled it — commonly a Spring @ConfigurationProperties binding of an invalid enum value that resolves to null.","solutions":["Set the model explicitly: consumer.setMessageModel(MessageModel.CLUSTERING) (or BROADCASTING as needed)","Fix the config binding so invalid enum strings fail at load time rather than binding null","Remove any code path that assigns null to messageModel"],"exampleFix":"// before\nconsumer.setMessageModel(modelFromConfig); // null when unparsable\nconsumer.start();\n\n// after\nMessageModel model = modelFromConfig != null ? modelFromConfig : MessageModel.CLUSTERING;\nconsumer.setMessageModel(model);\nconsumer.start();","handlingStrategy":"validation","validationCode":"if (model == null) model = MessageModel.CLUSTERING; consumer.setMessageModel(model);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set the message model explicitly","Reject invalid enum values at config load time"],"tags":["rocketmq","pull-consumer","config","message-model","startup"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}