开发者社区> 问答> 正文

canal rocketMq动态topic无法匹配到topic

环境信息

mac

canal version 1.5 mysql version 5.7

public static boolean matchDynamicTopic(String name, String dynamicTopicConfigs) { if (StringUtils.isEmpty(dynamicTopicConfigs)) { return false; }

boolean res = false;
List<DynamicTopicData> datas = dynamicTopicDatas.get(dynamicTopicConfigs);
for (DynamicTopicData data : datas) {
    if (data.simpleName != null) {
        if (data.simpleName.equalsIgnoreCase(name)) {
            res = true;
            break;
        }
    } else if (name.contains(".")) {
        if (data.tableRegexFilter != null && data.tableRegexFilter.filter(name)) {
            res = true;
            break;
        }
    } else {
        if (data.schemaRegexFilter != null && data.schemaRegexFilter.filter(name)) {
            res = true;
            break;
        }
    }
}
return res;

}

canal.mq.dynamicTopic=canal_tms_delivery_order_detail:tms_0.tms_delivery_order_detail_..,canal_tms_delivery_order_settlement:tms_0.tms_delivery_order_settlement_..,canal_tms_delivery_order_logistics:tms_0.tms_delivery_order_logistics_..,canal_tms_delivery_order:tms_0.tms_delivery_order_..

动态topic无法匹配:因为data.tableRegexFilter为空

canal.mq.dynamicTopic=canal_tms_delivery_order_detail:tms_0.tms_delivery_order_detail_..,canal_tms_delivery_order_settlement:tms_0.tms_delivery_order_settlement_..,canal_tms_delivery_order_logistics:tms_0.tms_delivery_order_logistics_..,canal_tms_delivery_order:tms_0.tms_delivery_order_.. 这种也不行,我调试发现表达式多个.导致无法匹配

原提问者GitHub用户god8816

展开
收起
山海行 2023-04-27 11:54:18 146 0
1 条回答
写回答
取消 提交回答
  • 转义符需要双斜杠

    原回答者GitHub用户agapple

    2023-04-27 21:15:19
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
基于 RocketMQ+ Knative 驱动云原生 Ser 立即下载
基于 RocketMQ + Knative 驱动云原生 Serverless 应用 立即下载
RocketMQ Operator-K8s平台自动化部署工具 立即下载