【问题标题】:Kafka connect database source connector : how to copy data from foreign keyKafka连接数据库源连接器:如何从外键复制数据
【发布时间】:2020-12-29 22:22:43
【问题描述】:

我正在使用数据库源连接器将数据从我的 Postgres 数据库表移动到 Kafka 主题。我有一个订单表,其中包含使用 customerNumber 字段的客户表的外键。

下面是将订单复制到 Kafka 但没有客户数据到 JSON 的连接器。我正在研究如何将客户订单的完整对象构造成 JSON。

连接器是:

{
"name": "SOURCE_CONNECTOR",
"config": {
    "connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
    "transforms.createKey.type": "org.apache.kafka.connect.transforms.ValueToKey",
    "connection.password": "postgres_pwd",
    "transforms.cast.type": "org.apache.kafka.connect.transforms.Cast$Value",
    "transforms.cast.spec": "amount:float64",
    "tasks.max": "1",
    "transforms": "cast,createKey,extractInt",
    "transforms.extractInt.type": "org.apache.kafka.connect.transforms.ExtractField$Key",
    "batch.max.rows": "25",
    "table.whitelist": "orders",
    "mode": "bulk",
    "topic.prefix": "data_",
    "transforms.extractInt.field": "uuid",
    "connection.user": "postgres_user",
    "transforms.createKey.fields": "uuid",
    "poll.interval.ms": "3600000",
    "sql.quote.identifiers": "false",
    "name": "SOURCE_CONNECTOR",
    "numeric.mapping": "best_fit",
    "connection.url": "url"
    }
  }

【问题讨论】:

    标签: jdbc apache-kafka apache-kafka-connect confluent-platform


    【解决方案1】:

    您可以使用Query-based ingest。只需指定 query config 选项即可。

    【讨论】:

      猜你喜欢
      • 2019-11-09
      • 2017-08-05
      • 1970-01-01
      • 2018-02-19
      • 2011-06-10
      • 2019-05-28
      • 2019-04-24
      • 2018-07-29
      • 1970-01-01
      相关资源
      最近更新 更多