You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

JDBC Source Connector能否使用静态目标Topic名替代源表名?

Answer

Absolutely! You can completely bypass the auto-generated topic names (built from topic.prefix + source table name) and define static, custom topic names for each of your tables using the JDBC Source Connector's configuration options. Here's how to make it work:

Key Configuration Properties

The core property you’ll use is topic.map, which lets you explicitly map each source table to a desired Kafka topic name. Pair this with either table.whitelist (for exact table matches) or table.inclusion.regex (for regex-based table selection) to specify which tables the connector should process.

Example Configuration

Suppose you have a source table named users$public (with the special $ character) and want to send its data to a clean Kafka topic called blah-users-public. Your connector config would look like this:

name=jdbc-source-custom-topics
connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
tasks.max=1
connection.url=jdbc:your-database-url-here
connection.user=your-username
connection.password=your-password
mode=incrementing
incrementing.column.name=id
table.whitelist=users$public
topic.map=users$public:blah-users-public

How It Works

  • table.whitelist tells the connector to only process the users$public table.
  • topic.map overrides the default naming logic: instead of creating blah-users$public (from topic.prefix + table name), it uses your explicitly defined blah-users-public topic.

Additional Tips

  • If you’re using topic.map, you don’t need the topic.prefix property anymore—since you’re defining topics directly.
  • For multiple tables, add more entries to topic.map separated by commas:
    table.whitelist=users$public,orders$private
    topic.map=users$public:blah-users-public,orders$private:blah-orders-private
    
  • Ensure target Kafka topics exist already, or enable auto.create.topics.enable on your cluster (though explicit topic creation is recommended for production).
  • If using regex to match tables (via table.inclusion.regex), note that topic.map still requires exact table-to-topic mappings—regex isn’t supported in the map itself.

Content of the question originates from Stack Exchange, asked by Sahas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 07:34:06