简体   繁体   English

如何在 JDBC Sink Connector 配置中添加多个主题并获取多个目标表中的主题数据?

[英]How to add multiple topics in JDBC Sink Connector configuration and get topics data in multiple target tables?

Below is my JDBC-Sink connector configuration:下面是我的 JDBC-Sink 连接器配置:

connector.class=io.confluent.connect.jdbc.JdbcSinkConnector
behavior.on.null.values=ignore
table.name.format=kafka_Address_V1, kafka_Attribute_V1
connection.password=***********
topics=Address,Attribute
task.max=3
batch.size=500
value.converter.value.subject.name.strategy=io.confluent.kafka.serializers.subject.RecordNameStrategy
value.converter.schema.registry.url=http://localhost:8081
auto.evolve=true
connection.user=user
name=sink-jdbc-connector
errors.tolerance=all
auto.create=true
value.converter=io.confluent.connect.avro.AvroConverter
connection.url=jdbc:sqlserver://localhost:DB;
insert.mode=upsert
key.converter=io.confluent.connect.avro.AvroConverter
key.converter.schema.registry.url=http://localhost:8081
pk.mode=record_value
pk.fields=id

If I use this configuration I am getting single table in target database in this kafka_Address_V1, kafka_Attribute_V1 format, which is combination of these two.如果我使用此配置,我将在目标数据库中以这种 kafka_Address_V1、kafka_Attribute_V1 格式获取单个表,这是这两者的组合。

在此处输入图像描述

Please let me know how can I use to store different topics data in different Tables by using JDBC-Sink Connector.请让我知道如何使用 JDBC-Sink 连接器将不同的主题数据存储在不同的表中。

Per the docs , table.name.format takes a single value, and defaults to using the topic name itself.根据docstable.name.format采用单个值,并默认使用主题名称本身。

To achieve what you want you can use the RegExRouter Single Message Transform to modify the topic as its processed by Kafka Connect要实现您想要的,您可以使用RegExRouter Single Message Transform将主题修改为由 Kafka Connect 处理

Try this:尝试这个:

transforms                             =changeTopicName
transforms.changeTopicName.type        =org.apache.kafka.connect.transforms.RegexRouter
transforms.changeTopicName.regex       =(.*)
transforms.changeTopicName.replacement =kafka_$1_V1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在jdbc连接器中的kafka中创建多个主题和多个表? - how to create multiple topics and multiple table in kafka in jdbc connector? Kafka/questDB JDBC 接收器连接器:未使用“topics.regex”创建的表 - Kafka/questDB JDBC Sink Connector: tables not created using "topics.regex" Kafka Connect JDBC Sink-topic.regex不起作用 - Kafka Connect JDBC Sink - topics.regex not working 使用 kafka-connect 从多个主题更新到多个表 - Upserting into multiple tables from multiples topics using kafka-connect 如何使用主题正则表达式选项创建具有多个主题的JDBC接收器连接器 - How to create the JDBC sink connector with multiple topic using topic regex option Kafka JDBC 源连接器:从列值创建主题 - Kafka JDBC Source connector: create topics from column values 如何使用多个表在JDBC连接中获取数据? - How to use multiple tables to get the data in JDBC connectivity? 如果所有源数据库中的主键相同,我们可以为多个源数据库制作单个 JDBC 接收器连接器吗? - Can we make Single JDBC Sink Connector for multiple source db if primary key is same in all source DB? Kafka JDBC Sink Connector 在雪花中找不到表 - Kafka JDBC Sink Connector can't find tables in Snowflake 学习JDBC应该涵盖的主题 - The topics that should be covered for learning JDBC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM