如何使用路由配置多个表到Kafka主题

huangapple go评论60阅读模式
英文:

How to configure multiple tables into kafka topic using routing

问题

我有一个包含n个租户的数据库,每个租户都有一个Mongo集合。我想将所有表格添加到一个Debezium连接器中,并将它们连接到指定的主题。例如:

  • tenant1.circles->circleTopic,
  • tenant2.circles->circleTopic,
  • tenant1.triangle->triangleTopic,
  • tenant2.triangle->triangleTopic

我尝试过将一个集合与一个主题关联,这样可以正常工作,如果我将更多集合添加到第一个主题也可以正常工作,但是我不知道如何添加第二部分。

下面是仅适用于一个集合的示例:

"collection.whitelist": "tenant1.triangle, tenant2.triangle, tenant3.triangle",
"transforms": "regexRouter",
"transforms.regexRouter.regex": "(.*)",
"transforms.regexRouter.type": "org.apache.kafka.connect.transforms.RegexRouter",
"transforms.regexRouter.replacement": "triangleTopic"

现在我想要的是在集合白名单中添加第二个集合并将其发送到单独的主题。

我对Debezium连接器和转换的使用相对新手,阅读在线文档没有帮助。

英文:

I have a db with n tenants that has a mongo collection for each tenant. I want to add all tables to a debezium connector and link them to one topic specified. ex

  • tenant1.circles->circleTopic,
  • tenant2.circles->circleTopic
  • tenant1.triangle->triangleTopic
  • tenant2.triangle->triangleTopic

I tried with one collection to one topic and it works fine and it works fine if I add more collections to the first topic but I'm lost on how to add the second part.

Example that works fine for only 1 collection.

 "collection.whitelist": "tenant1.triangle, tenant2.triangle, tenant3.triangle",
 "transforms": "regexRouter",
 "transforms.regexRouter.regex": "(.*)",
 "transforms.regexRouter.type": "org.apache.kafka.connect.transforms.RegexRouter",
 "transforms.regexRouter.replacement": "triangleTopic"

Now what I want is in collection whitelist to add like a second collection and go to a separate topic.

I'm kinda new to this debezium connector and transform stuff and reading online did not help.

答案1

得分: 0

"transforms.regexRouter.regex": "tenant\\d+\\.([a-z]+)s?",
"transforms.regexRouter.replacement": "$1Topic"

https://docs.confluent.io/platform/current/connect/transforms/regexrouter.html

请注意,这可能会导致 circlesTopic,而不是 circleTopic

英文:

I would try something like

"transforms.regexRouter.regex": "tenant\d+\.([a-z]+)s?",
"transforms.regexRouter.replacement": "$1Topic"

https://docs.confluent.io/platform/current/connect/transforms/regexrouter.html

Note that this may result in circlesTopic, not circleTopic

huangapple
  • 本文由 发表于 2023年6月29日 19:06:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/76580459.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定