18 Haziran 2023 Pazar

Debezium Connector transforms - ExtractNewRecordState - Sadece Değişen Alan Gelir

Giriş
Şu iki satırı yazmak gerekir.
1. transforms": "unwrap"
2. "transforms.unwrap.type": "io.debezium.transforms.ExtractNewRecordState",
Böylece çıktıda  before alanı hep null gelir. Yani şöyledir
{
"source": { ... }, "before": null, "after": { "id": 1, "name": "John Doe", "age": 30 }, "op": "c", "ts_ms": 1654316585000 }
Açıklaması şöyle
By default, Debezium sends all events in an envelope that includes many pieces of information about the change captured. I’m only interested in reading the changed value here, so the command tells Kafka Connect to keep this information and discard the rest.
Örnek
Şöyle yaparız
{
  "name":"customer-connector",
  "config":{
   "connector.class":"io.debezium.connector.mysql.MySqlConnector",
   "tasks.max":"1",
   "database.hostname":"localhost",
   "database.port":"3306",
   "database.user":"root",
   "database.password":"mysqlpwd",
   "database.server.id":"184054",
   "database.server.name":"mysql",
   "database.whitelist":"customers_db",
   "database.history.kafka.bootstrap.servers":"localhost:9092",
   "database.history.kafka.topic":"schema-changes.customers",
   "transforms":"unwrap",    "transforms.unwrap.type":"io.debezium.transforms.ExtractNewRecordState",
    "transforms.unwrap.drop.tombstones":false,
    "transforms.unwrap.delete.handling.mode":"rewrite"
   }
}

Hiç yorum yok:

Yorum Gönder

LIMIT ve Covering Index + Subquery

Örnek Şöyle yaparız SELECT t1.name, t1.age, t1.gender, t1.create_time FROM student as t1    INNER JOIN     (SELECT id FROM student ORDER BY ...