{"record":{"id":"f97dc44cc6b7a0f5","repo":"apache/rocketmq","slug":"allocatemessagequeuestrategy-is-null-f97dc4","errorCode":null,"errorMessage":"allocateMessageQueueStrategy is null","messagePattern":"allocateMessageQueueStrategy is null","errorType":"exception","errorClass":"MQClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java","lineNumber":437,"sourceCode":"            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);\n        }\n    }\n\n    public PullAPIWrapper getPullAPIWrapper() {\n        return pullAPIWrapper;\n    }\n\n    private void startPullTask(Collection<MessageQueue> mqSet) {","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultLitePullConsumerImpl.java#L419-L455","documentation":"MQClientException from DefaultLitePullConsumerImpl.checkConfig during start(): allocateMessageQueueStrategy is null. This strategy distributes queues among group members during rebalance; the constructor normally installs a default (AllocateMessageQueueAveragely), so a null means it was explicitly cleared — usually by custom construction or reflection-based config.","triggerScenarios":"Calling consumer.setAllocateMessageQueueStrategy(null) (directly or via a config binder injecting null) and then start(). Also possible with custom factory/builder code that sets fields via reflection and skips the strategy.","commonSituations":"Config binding with an optional allocate strategy key that maps to null when absent; DI frameworks creating the consumer via a nonstandard constructor path that bypasses defaults; partial copies of producer/consumer config objects.","solutions":["Do not null the strategy; rely on the constructor default or set one explicitly: consumer.setAllocateMessageQueueStrategy(new AllocateMessageQueueAveragely())","Fix config binding to keep the default when the property is missing","Add a startup assertion that core consumer settings are non-null before start()"],"exampleFix":"// before\nconsumer.setAllocateMessageQueueStrategy(\n    props.getStrategy()); // null when not configured\nconsumer.start();\n\n// after\nAllocateMessageQueueStrategy s = Optional.ofNullable(props.getStrategy())\n    .orElseGet(AllocateMessageQueueAveragely::new);\nconsumer.setAllocateMessageQueueStrategy(s);\nconsumer.start();","handlingStrategy":"validation","validationCode":"if (consumer.getAllocateMessageQueueStrategy() == null) {\n    consumer.setAllocateMessageQueueStrategy(new AllocateMessageQueueAveragely());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not overwrite DI-managed defaults with nullable config values","Validate core consumer fields before start()","Prefer leaving framework defaults untouched unless custom allocation is needed"],"tags":["rocketmq","config","consumer","lite-pull","rebalance"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}