{"record":{"id":"2ba777d9454ab618","repo":"apache/rocketmq","slug":"allocatemessagequeuestrategy-is-null-2ba777","errorCode":null,"errorMessage":"allocateMessageQueueStrategy is null","messagePattern":"allocateMessageQueueStrategy is null","errorType":"validation","errorClass":"MQClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java","lineNumber":804,"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        // 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),\n                null);\n        }\n    }\n\n    private void copySubscription() throws MQClientException {\n        try {\n            Set<String> registerTopics = this.defaultMQPullConsumer.getRegisterTopics();\n            if (registerTopics != null) {","sourceCodeStart":786,"sourceCodeEnd":822,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java#L786-L822","documentation":"Thrown by checkConfig() during start() when allocateMessageQueueStrategy is null. The allocation strategy decides how queues are distributed among consumers in a group during rebalance; the pull consumer implementation requires one to be configured even though pull consumers often use manual allocation.","triggerScenarios":"setAllocateMessageQueueStrategy(null) before start(); constructing the impl layer directly (DefaultMQPullConsumerImpl) without propagating the default strategy from the facade class.","commonSituations":"Like messageModel, DefaultMQPullConsumer normally defaults this field (AllocateMessageQueueAveragely); hitting the error implies explicit nulling — typically a config binder or a test constructing the consumer via a path that skips field defaults.","solutions":["Set the strategy explicitly: consumer.setAllocateMessageQueueStrategy(new AllocateMessageQueueAveragely())","Remove config-driven null assignment; validate the property resolves to a real strategy instance","For manual/assigned pull patterns use AllocateMessageQueueByConfig with your fixed queue list"],"exampleFix":"// before\nconsumer.setAllocateMessageQueueStrategy(strategy); // strategy null\nconsumer.start();\n\n// after\nAllocateMessageQueueStrategy strategy =\n    strategyFromConfig != null ? strategyFromConfig : new AllocateMessageQueueAveragely();\nconsumer.setAllocateMessageQueueStrategy(strategy);\nconsumer.start();","handlingStrategy":"validation","validationCode":"if (strategy == null) strategy = new AllocateMessageQueueAveragely();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set the allocation strategy explicitly","For fixed assignments use AllocateMessageQueueByConfig"],"tags":["rocketmq","pull-consumer","config","rebalance","allocation-strategy"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}