INVALID_TOPIC_EXCEPTION产生原因分析
亲测有效(虽然不一定是最完美的解决办法)
1 .topic命名原则
topic命名最好不要带下划线"_",容易和kafka默认topic产生冲突
2.注意canal.mq.dynamicTopic的使用
①canal.instance.filter.regex,后面配置该mysql下,你要监听的数据库下的对应的表,例如
canal.instance.filter.regex=user1.table1,user2.table2,user3.table3
多个规则,或者表用 “,” 隔开
②canal.mq.topic 这一项最好不要注释,可以创建一个不适用的topic配置该项。
canal.mq.topic=topic-test
原因:如果有一些不符合dynamicTopic匹配的语句的消息会发送到该topic而避免报错 INVALID_TOPIC_EXCEPTION
③canal.mq.dynamicTopic的配置同上面canal.instance.filter.regex的过滤内容一致,需要在每个表前面加上你想发送到的对应topic
注意用 “,” 隔开,并且 “.” 要使用 “\” 转义
例如:
canal.mq.dynamicTopic=topic1:user1\\.table1,topic2:user2\\.table2,topic3:user3\\.table3
最后附上官网正则表达式,大家可以按需更改
https://github.com/alibaba/canal/wiki/AdminGuide
对你有帮助的话记得回来点赞~