{"record":{"id":"3a0c9d661d878096","repo":"apache/rocketmq","slug":"consumeconcurrentlymaxspan-out-of-range-1-65535","errorCode":null,"errorMessage":"consumeConcurrentlyMaxSpan Out of range [1, 65535]","messagePattern":"consumeConcurrentlyMaxSpan Out of range \\[1, 65535\\]","errorType":"validation","errorClass":"MQClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java","lineNumber":1127,"sourceCode":"        if (this.defaultMQPushConsumer.getConsumeThreadMax() < 1 || this.defaultMQPushConsumer.getConsumeThreadMax() > 1000) {\n            throw new MQClientException(\n                \"consumeThreadMax Out of range [1, 1000]\"\n                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),\n                null);\n        }\n\n        // consumeThreadMin can't be larger than consumeThreadMax\n        if (this.defaultMQPushConsumer.getConsumeThreadMin() > this.defaultMQPushConsumer.getConsumeThreadMax()) {\n            throw new MQClientException(\n                \"consumeThreadMin (\" + this.defaultMQPushConsumer.getConsumeThreadMin() + \") \"\n                    + \"is larger than consumeThreadMax (\" + this.defaultMQPushConsumer.getConsumeThreadMax() + \")\",\n                null);\n        }\n\n        // consumeConcurrentlyMaxSpan\n        if (this.defaultMQPushConsumer.getConsumeConcurrentlyMaxSpan() < 1\n            || this.defaultMQPushConsumer.getConsumeConcurrentlyMaxSpan() > 65535) {\n            throw new MQClientException(\n                \"consumeConcurrentlyMaxSpan Out of range [1, 65535]\"\n                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),\n                null);\n        }\n\n        // pullThresholdForQueue\n        if (this.defaultMQPushConsumer.getPullThresholdForQueue() < 1 || this.defaultMQPushConsumer.getPullThresholdForQueue() > 65535) {\n            throw new MQClientException(\n                \"pullThresholdForQueue Out of range [1, 65535]\"\n                    + FAQUrl.suggestTodo(FAQUrl.CLIENT_PARAMETER_CHECK_URL),\n                null);\n        }\n\n        // pullThresholdForTopic\n        if (this.defaultMQPushConsumer.getPullThresholdForTopic() != -1) {\n            if (this.defaultMQPushConsumer.getPullThresholdForTopic() < 1 || this.defaultMQPushConsumer.getPullThresholdForTopic() > 6553500) {\n                throw new MQClientException(\n                    \"pullThresholdForTopic Out of range [1, 6553500]\"","sourceCodeStart":1109,"sourceCodeEnd":1145,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java#L1109-L1145","documentation":"checkConfig() validates consumeConcurrentlyMaxSpan — the maximum difference (in messages) allowed between the first and last message queued for a queue before flow-controlling pulls — which must be in [1, 65535]. Default is 2000, so an out-of-range value was explicitly set.","triggerScenarios":"setConsumeConcurrentlyMaxSpan(0) or a value above 65535; large values copied from memory-size tuning with a wrong unit; -1 sentinels from 'unlimited' conventions.","commonSituations":"Trying to disable span-based flow control by setting 0 or a huge number; config generation templates defaulting numeric fields to 0.","solutions":["Keep the value in [1,65535]; the default 2000 suits most consumers","To relax flow control, raise it moderately (e.g. 4096) rather than disabling it","If slow consumption triggers flow control, tune consumeThreadMin/Max and the consumer logic before raising the span"],"exampleFix":"// before\nconsumer.setConsumeConcurrentlyMaxSpan(0); // meant 'unlimited'\n\n// after\nconsumer.setConsumeConcurrentlyMaxSpan(2000); // default, or up to 65535","handlingStrategy":"validation","validationCode":"int span = config.getConsumeConcurrentlyMaxSpan();\nif (span < 1 || span > 65535) throw new IllegalArgumentException(\"consumeConcurrentlyMaxSpan must be in [1,65535]: \" + span);\nconsumer.setConsumeConcurrentlyMaxSpan(span);","typeGuard":"boolean inSpanRange(int v) { return v >= 1 && v <= 65535; }","tryCatchPattern":null,"preventionTips":["Do not use 0 to mean 'unlimited' for flow-control settings","Validate every flow-control numeric against its documented range at config load"],"tags":["rocketmq","config","flow-control","validation"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}