{"record":{"id":"5342bc472f9ffb85","repo":"alibaba/canal","slug":"mq-not-support-this-method-5342bc","errorCode":null,"errorMessage":"mq not support this method","messagePattern":"mq not support this method","errorType":"exception","errorClass":"CanalClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/com/alibaba/otter/canal/client/rocketmq/RocketMQCanalConnector.java","lineNumber":302,"sourceCode":"            }\n        } finally {\n            this.lastGetBatchMessage = null;\n        }\n    }\n\n    @Override\n    public void rollback() throws CanalClientException {\n        try {\n            if (this.lastGetBatchMessage != null) {\n                this.lastGetBatchMessage.fail();\n            }\n        } finally {\n            this.lastGetBatchMessage = null;\n        }\n    }\n\n    public Message get(int batchSize) throws CanalClientException {\n        throw new CanalClientException(\"mq not support this method\");\n    }\n\n    @Override\n    public Message get(int batchSize, Long timeout, TimeUnit unit) throws CanalClientException {\n        throw new CanalClientException(\"mq not support this method\");\n    }\n\n    @Override\n    public Message getWithoutAck(int batchSize) throws CanalClientException {\n        throw new CanalClientException(\"mq not support this method\");\n    }\n\n    @Override\n    public Message getWithoutAck(int batchSize, Long timeout, TimeUnit unit) throws CanalClientException {\n        throw new CanalClientException(\"mq not support this method\");\n    }\n\n    @Override","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/client/src/main/java/com/alibaba/otter/canal/client/rocketmq/RocketMQCanalConnector.java#L284-L320","documentation":"Thrown by RocketMQCanalConnector.get(int batchSize) — the single-Message batch-pull API inherited from the CanalConnector contract. The RocketMQ connector is push-based (DefaultMQPushConsumer delivers into an internal queue) and only supports the List-returning getList/getFlatList methods; the batchSize-oriented single-Message pull methods are unsupported.","triggerScenarios":"Calling connector.get(batchSize) on a RocketMQCanalConnector; generic CanalConnector code written for the TCP SimpleCanalConnector invoked against an MQ connector without checking the runtime type.","commonSituations":"Shared abstraction code that calls get(int) regardless of connector type; migrating a TCP-mode client to RocketMQ without switching to the List API; copy-pasting example code targeting the embedded/TCP connector.","solutions":["Use getList(Long timeout, TimeUnit unit) instead of get(int batchSize) for RocketMQ.","Branch connector-specific logic by type (instanceof CanalMQConnector) before choosing the API.","Switch to getFlatList() if flatMessage mode is enabled."],"exampleFix":"// before\nMessage m = connector.get(1000);\n// after\nList<Message> batch = connector.getList(1L, TimeUnit.SECONDS);","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Route to the correct API based on connector type before fetching.\nif (connector instanceof CanalMQConnector) {\n    // use getList(timeout, unit) / getFlatList(timeout, unit)\n} else {\n    // SimpleCanalConnector: connector.get(batchSize) is valid\n}","tryCatchPattern":null,"preventionTips":["Do not call get(int) on a RocketMQ/RabbitMQ connector; use the List-returning API.","Branch shared consumer logic by CanalMQConnector instanceof.","When migrating from TCP mode, switch all get/ack calls to the List API."],"tags":["rocketmq","canal-client","unsupported-api","api-mismatch"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}