开发者社区> 问答> 正文

运行客户端 batchId偶尔出现冲突问题

batchId:2176966 is not the firstly:2176965 at com.alibaba.otter.canal.client.impl.SimpleCanalConnector.receiveMessages(SimpleCanalConnector.java:302) at com.alibaba.otter.canal.client.impl.SimpleCanalConnector.getWithoutAck(SimpleCanalConnector.java:279) at com.alibaba.otter.canal.client.impl.SimpleCanalConnector.getWithoutAck(SimpleCanalConnector.java:252) at com.yagou.yggx.provider.datasync.start.AbstractCanalStart.process(AbstractCanalStart.java:115)

下面是代码:

int batchSize = 5 * 1024; while (running) { try { MDC.put("destination", destination); connector.connect(); connector.subscribe(); while (running) { // 获取指定数量的数据 Message message = connector.getWithoutAck(batchSize); long batchId = message.getId(); int size = message.getEntries().size(); List entrys = message.getEntries(); if (batchId == -1 || size == 0) { // try {Thread.sleep(1000); // } catch (InterruptedException e) { } } else { DataSourceListenerInformation.comeOutEntry(entrys); } connector.ack(batchId); // 提交确认

原提问者GitHub用户youngJavabird

展开
收起
绿子直子 2023-05-09 15:20:57 65 0
1 条回答
写回答
取消 提交回答
  • 一个destination,对应一个消费端。多个消费端同时消费同一个destination,就会报batchId不存在或不是位点

    原回答者GitHub用户youngJavabird

    2023-05-10 10:39:37
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载