{"record":{"id":"a624f688e26051b7","repo":"apache/rocketmq","slug":"messagemodel-is-null-a624f6","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/DefaultMQPushConsumerImpl.java","lineNumber":1045,"sourceCode":"\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),\n                null);\n        }\n\n        if (null == this.defaultMQPushConsumer.getConsumeFromWhere()) {\n            throw new MQClientException(\n                \"consumeFromWhere is null\"\n                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),\n                null);\n        }\n\n        Date dt = UtilAll.parseDate(this.defaultMQPushConsumer.getConsumeTimestamp(), UtilAll.YYYYMMDDHHMMSS);\n        if (null == dt) {\n            throw new MQClientException(\n                \"consumeTimestamp is invalid, the valid format is yyyyMMddHHmmss,but received \"\n                    + this.defaultMQPushConsumer.getConsumeTimestamp()\n                    + \" \" + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL), null);","sourceCodeStart":1027,"sourceCodeEnd":1063,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java#L1027-L1063","documentation":"checkConfig() requires a MessageModel (CLUSTERING or BROADCASTING) on the consumer. DefaultMQPushConsumer normally initializes messageModel to CLUSTERING, so a null value means something explicitly set it to null before start().","triggerScenarios":"Calling setMessageModel(null); a mapping layer (DI, config binder) assigning null when the configured string does not match a property and binds null instead of failing.","commonSituations":"Custom config binding that converts an unknown enum string to null; test code constructing the consumer with reflection/mocks that leave messageModel null; framework deserialization of consumer settings.","solutions":["Do not call setMessageModel(null); pick CLUSTERING (default, load-balanced) or BROADCASTING explicitly","Fix the config binder so invalid enum values throw instead of producing null","Set the model explicitly in your consumer factory so intent is obvious"],"exampleFix":"// before\nconsumer.setMessageModel(null); // e.g. bad enum binding\n\n// after\nconsumer.setMessageModel(MessageModel.CLUSTERING); // or BROADCASTING, explicitly","handlingStrategy":"validation","validationCode":"MessageModel model = config.getModel() != null ? config.getModel() : MessageModel.CLUSTERING;\nconsumer.setMessageModel(model);","typeGuard":"boolean isValidMessageModel(MessageModel m) { return m == MessageModel.CLUSTERING || m == MessageModel.BROADCASTING; }","tryCatchPattern":null,"preventionTips":["Always set messageModel explicitly from a closed enum in config","Reject unknown enum strings during config binding rather than coercing to null"],"tags":["rocketmq","config","message-model","validation"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}