{"record":{"id":"bf395d3e75762adc","repo":"apache/rocketmq","slug":"sendselectimpl-call-timeout","errorCode":null,"errorMessage":"sendSelectImpl call timeout","messagePattern":"sendSelectImpl call timeout","errorType":"exception","errorClass":"RemotingTooMuchRequestException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java","lineNumber":707,"sourceCode":"\n        TopicPublishInfo topicPublishInfo = this.tryToFindTopicPublishInfo(msg.getTopic());\n        if (topicPublishInfo != null && topicPublishInfo.ok()) {\n            MessageQueue mq = null;\n            try {\n                List<MessageQueue> messageQueueList =\n                        mQClientFactory.getMQAdminImpl().parsePublishMessageQueues(topicPublishInfo.getMessageQueueList());\n                Message userMessage = MessageAccessor.cloneMessage(msg);\n                String userTopic = NamespaceUtil.withoutNamespace(userMessage.getTopic(), mQClientFactory.getClientConfig().getNamespace());\n                userMessage.setTopic(userTopic);\n\n                mq = mQClientFactory.getClientConfig().queueWithNamespace(selector.select(messageQueueList, userMessage, arg));\n            } catch (Throwable e) {\n                throw new MQClientException(\"select message queue threw exception.\", e);\n            }\n\n            long costTime = System.currentTimeMillis() - beginStartTime;\n            if (timeout < costTime) {\n                throw new RemotingTooMuchRequestException(\"sendSelectImpl call timeout\");\n            }\n            if (mq != null) {\n                return mq;\n            } else {\n                throw new MQClientException(\"select message queue return null.\", null);\n            }\n        }\n\n        validateNameServerSetting();\n        throw new MQClientException(\"No route info for this topic, \" + msg.getTopic(), null);\n    }\n\n    public MessageQueue selectOneMessageQueue(final TopicPublishInfo tpInfo, final String lastBrokerName, final boolean resetIndex) {\n        return this.mqFaultStrategy.selectOneMessageQueue(tpInfo, lastBrokerName, resetIndex);\n    }\n\n    public void updateFaultItem(final String brokerName, final long currentLatency, boolean isolation,\n                                boolean reachable) {","sourceCodeStart":689,"sourceCodeEnd":725,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java#L689-L725","documentation":"RemotingTooMuchRequestException thrown from invokeMessageQueueSelector when the elapsed time from method entry to just before sending (state check, message validation, topic-route lookup, and selector execution) already exceeds the configured timeout. No network call has necessarily failed - the client is enforcing its own deadline: spending the whole budget locally means the remaining timeout passed to sendKernelImpl would be <= 0.","triggerScenarios":"triggerScenarios","commonSituations":"commonSituations","solutions":["Increase the timeout passed to send(msg, selector, arg, timeout) or producer.setSendMsgTimeout(...) to cover route lookup + selector + network send","Warm the route cache at startup by pre-calling fetchPublishMessageQueues or setting a topicPublishInfo before the first timed request","Move slow logic out of MessageQueueSelector.select - it runs inside the timeout window; precompute the shard key and use a cheap selector","Measure with beginStartTime cost logging to confirm where the budget goes before raising the timeout"],"exampleFix":"// before\nproducer.send(msg, selector, key, 100L); // route lookup alone takes ~150ms\n// after\nproducer.setSendMsgTimeout(3_000);\nproducer.send(msg, selector, key, 3_000L);","handlingStrategy":"validation","validationCode":" long t0 = System.currentTimeMillis();\n// warm route cache before timed sends\nproducer.fetchPublishMessageQueues(topic);\n// budget = warm path cost + network RTT\nlong budget = Math.max(defaultTimeout, (System.currentTimeMillis() - t0) + expectedRttMs * 2);","typeGuard":null,"tryCatchPattern":"try {\n    producer.send(msg, selector, arg, timeout);\n} catch (RemotingTooMuchRequestException e) { // client-side deadline, no RPC sent or budget exhausted\n    retryWithLargerBudget(msg, selector, arg, timeout * 2);\n}","preventionTips":["Warm topic routes at startup for all hot topics","Keep MessageQueueSelector free of blocking calls","Set timeout >= route-lookup + selector + (retries+1)*RTT","Pass per-call timeouts rather than shrinking the global sendMsgTimeout"],"tags":["rocketmq","producer","timeout","message-queue-selector"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}