alibaba/canal · error · CanalClientException

mq not support this method

Error message

mq not support this method

What it means

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.

Source

Thrown at client/src/main/java/com/alibaba/otter/canal/client/rocketmq/RocketMQCanalConnector.java:302

            }
        } finally {
            this.lastGetBatchMessage = null;
        }
    }

    @Override
    public void rollback() throws CanalClientException {
        try {
            if (this.lastGetBatchMessage != null) {
                this.lastGetBatchMessage.fail();
            }
        } finally {
            this.lastGetBatchMessage = null;
        }
    }

    public Message get(int batchSize) throws CanalClientException {
        throw new CanalClientException("mq not support this method");
    }

    @Override
    public Message get(int batchSize, Long timeout, TimeUnit unit) throws CanalClientException {
        throw new CanalClientException("mq not support this method");
    }

    @Override
    public Message getWithoutAck(int batchSize) throws CanalClientException {
        throw new CanalClientException("mq not support this method");
    }

    @Override
    public Message getWithoutAck(int batchSize, Long timeout, TimeUnit unit) throws CanalClientException {
        throw new CanalClientException("mq not support this method");
    }

    @Override

View on GitHub (pinned to 87be50e876)

Solutions

  1. Use getList(Long timeout, TimeUnit unit) instead of get(int batchSize) for RocketMQ.
  2. Branch connector-specific logic by type (instanceof CanalMQConnector) before choosing the API.
  3. Switch to getFlatList() if flatMessage mode is enabled.

Example fix

// before
Message m = connector.get(1000);
// after
List<Message> batch = connector.getList(1L, TimeUnit.SECONDS);
Defensive patterns

Strategy: type-guard

Type guard

// Route to the correct API based on connector type before fetching.
if (connector instanceof CanalMQConnector) {
    // use getList(timeout, unit) / getFlatList(timeout, unit)
} else {
    // SimpleCanalConnector: connector.get(batchSize) is valid
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14). Data as JSON: /api/errors/5342bc472f9ffb85. Report an issue: GitHub.