{"record":{"id":"35870fa3d4a42e93","repo":"apache/rocketmq","slug":"messagemodel-is-null","errorCode":null,"errorMessage":"messageModel is null","messagePattern":"messageModel is null","errorType":"exception","errorClass":"MQClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java","lineNumber":429,"sourceCode":"    }\n\n    private void checkConfig() throws MQClientException {\n        // Check consumerGroup\n        Validators.checkGroup(this.defaultLitePullConsumer.getConsumerGroup());\n\n        // Check consumerGroup name is not equal default consumer group name.\n        if (this.defaultLitePullConsumer.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        // Check messageModel is not null.\n        if (null == this.defaultLitePullConsumer.getMessageModel()) {\n            throw new MQClientException(\n                \"messageModel is null\"\n                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),\n                null);\n        }\n\n        // Check allocateMessageQueueStrategy is not null\n        if (null == this.defaultLitePullConsumer.getAllocateMessageQueueStrategy()) {\n            throw new MQClientException(\n                \"allocateMessageQueueStrategy is null\"\n                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),\n                null);\n        }\n\n        if (this.defaultLitePullConsumer.getConsumerTimeoutMillisWhenSuspend() < this.defaultLitePullConsumer.getBrokerSuspendMaxTimeMillis()) {\n            throw new MQClientException(\n                \"Long polling mode, the consumer consumerTimeoutMillisWhenSuspend must greater than brokerSuspendMaxTimeMillis\"\n                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),\n                null);","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java#L411-L447","documentation":"MQClientException from DefaultLitePullConsumerImpl.checkConfig during start(): messageModel is null. The clustering/broadcasting model must be set (a default normally exists), so a null model means code explicitly set it to null or a custom builder cleared it.","triggerScenarios":"Calling consumer.setMessageModel(null) (possibly via property binding that maps a missing config value to null) and then start(). Spring @Value or YAML-backed fields defaulting to null when the key is absent are a typical source.","commonSituations":"Configuration binding that injects null for a missing/misspelled messageModel property; test code copying constructor patterns from classes where the field was deliberately nulled; serialization frameworks restoring a consumer config without the model field.","solutions":["Set the model explicitly: consumer.setMessageModel(MessageModel.CLUSTERING) (or BROADCASTING)","Fix the property binding so absent values fall back to a default rather than null","Validate required config fields at application startup before creating the consumer"],"exampleFix":"// before: @Value missing -> null injected\nconsumer.setMessageModel(props.getMessageModel()); // null when property absent\n\n// after\nMessageModel model = props.getMessageModel() != null ? props.getMessageModel() : MessageModel.CLUSTERING;\nconsumer.setMessageModel(model);","handlingStrategy":"validation","validationCode":"if (consumer.getMessageModel() == null) {\n    consumer.setMessageModel(MessageModel.CLUSTERING);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default null config fields explicitly before start()","Test config binding with absent properties to catch null injection","Assert required settings in a startup validation routine"],"tags":["rocketmq","config","consumer","lite-pull","null-check"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}