{"record":{"id":"69d0fc8ba2cac15b","repo":"apache/rocketmq","slug":"unknown-exception","errorCode":null,"errorMessage":"unknown exception","messagePattern":"unknown exception","errorType":"exception","errorClass":"MQClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java","lineNumber":1216,"sourceCode":"            context.setProducerGroup(defaultMQProducer.getProducerGroup());\n            context.setBrokerAddr(brokerAddr);\n            context.setMessage(msg);\n            context.setMsgId(msgId);\n            context.setTransactionId(msg.getTransactionId());\n            context.setTransactionState(state);\n            context.setFromTransactionCheck(fromTransactionCheck);\n            executeEndTransactionHook(context);\n        }\n    }\n\n    /**\n     * DEFAULT ONEWAY -------------------------------------------------------\n     */\n    public void sendOneway(Message msg) throws MQClientException, RemotingException, InterruptedException {\n        try {\n            this.sendDefaultImpl(msg, CommunicationMode.ONEWAY, null, this.defaultMQProducer.getSendMsgTimeout());\n        } catch (MQBrokerException e) {\n            throw new MQClientException(\"unknown exception\", e);\n        }\n    }\n\n    /**\n     * KERNEL SYNC -------------------------------------------------------\n     */\n    public SendResult send(Message msg, MessageQueue mq)\n        throws MQClientException, RemotingException, MQBrokerException, InterruptedException {\n        return send(msg, mq, this.defaultMQProducer.getSendMsgTimeout());\n    }\n\n    public SendResult send(Message msg, MessageQueue mq, long timeout)\n        throws MQClientException, RemotingException, MQBrokerException, InterruptedException {\n        long beginStartTime = System.currentTimeMillis();\n        this.makeSureStateOK();\n        Validators.checkMessage(msg, this.defaultMQProducer);\n\n        if (!msg.getTopic().equals(mq.getTopic())) {","sourceCodeStart":1198,"sourceCodeEnd":1234,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java#L1198-L1234","documentation":"MQClientException('unknown exception') thrown by sendOneway when the underlying sendDefaultImpl raised an MQBrokerException - the broker actively returned an error response. ONEWAY normally ignores responses, but the remoting layer still surfaces broker-side errors, and sendOneway wraps them in this generic message (MQBrokerException cannot be declared on sendOneway's signature). The response code and remark of the cause carry the real diagnosis (e.g. MESSAGE_ILLEGAL, TOPIC_NOT_EXIST, SUBSCRIPTION_GROUP_NOT_EXIST, disk-full FLUSH_DISK_TIMEOUT).","triggerScenarios":"triggerScenarios","commonSituations":"commonSituations","solutions":["Inspect the cause: ((MQBrokerException) e.getCause()).getResponseCode() and getResponseRemark() tell exactly why the broker refused","Fix per the code: shrink/split message (check maxMessageSize on broker), create topic, fix ACL/permissions, or free disk / relax flush-disk settings","Consider whether ONEWAY is right: if you need to react to broker rejections, use SYNC send and handle SendResult","Add logging around sendOneway that unwraps and records MQBrokerException causes instead of swallowing them"],"exampleFix":"// before\ntry { producer.sendOneway(msg); } catch (MQClientException e) { log.error(\"send failed\", e); }\n// after\ntry { producer.sendOneway(msg); }\ncatch (MQClientException e) {\n    Throwable c = e.getCause();\n    if (c instanceof MQBrokerException) log.error(\"broker rejected: code={} remark={}\", ((MQBrokerException) c).getResponseCode(), ((MQBrokerException) c).getResponseRemark());\n    else log.error(\"send failed\", e);\n}","handlingStrategy":"try-catch","validationCode":" // pre-validate what the broker will check\nif (msg.getBody().length > producer.getMaxMessageSize()) {\n    throw new IllegalArgumentException(\"body exceeds maxMessageSize=\" + producer.getMaxMessageSize());\n}","typeGuard":null,"tryCatchPattern":"try {\n    producer.sendOneway(msg);\n} catch (MQClientException e) {\n    if (e.getCause() instanceof MQBrokerException) {\n        MQBrokerException be = (MQBrokerException) e.getCause();\n        log.error(\"broker rejected oneway: code={} remark={}\", be.getResponseCode(), be.getResponseRemark());\n        handleBrokerRejection(be); // dedup on message key if re-sending\n    } else throw e;\n}","preventionTips":["Always unwrap the MQBrokerException cause - its responseCode is the real diagnosis","Pre-validate message size/topic against broker limits before sending","If broker rejections matter to your flow, use SYNC send instead of ONEWAY","Keep message keys unique so any manual re-send after rejection is dedupable"],"tags":["rocketmq","producer","oneway","broker-error","wrapping"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}