英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论