簡體   English   中英

我無法使用 Debezium-Java 捕獲數據更改

[英]I am not able to capture data changes with Debezium-Java

我正在嘗試用 Java 制作一個 Debezium 示例。 每次在數據庫中刪除數據時,我都想捕獲它。 當應用程序運行時,它會在屏幕上打印以下日志:

Dec 10, 2022 10:18:46 PM com.github.shyiko.mysql.binlog.BinaryLogClient connect
INFO: Connected to localhost:3305 at binlog.000008/3443 (sid:10181, cid:41)

但是當我刪除數據庫中的某些內容時,debezium 無法捕獲它。

連接配置類

public DebeziumSignal connect(Connection data) {
    final Configuration configuration = DebeziumConfigLoader.load(data);

    engine = DebeziumEngine.create(ChangeEventFormat.of(Connect.class))
            .using(configuration.asProperties())
            .notifying(this::handleEvent)
            .build();

    return new DebeziumSignal(engine);
}

配置數據類:

public static Configuration load(Connection connection) {
    final MysqlConnection mysql = connection.getMysqlConnection();
    return Configuration.create()
            .with("name", "customer-mysql-connector")
            .with("connector.class", "io.debezium.connector.mysql.MySqlConnector")
            .with("offset.storage", "org.apache.kafka.connect.storage.FileOffsetBackingStore")
            .with("offset.flush.interval.ms", "60000")
            .with("database.hostname", mysql.getHost())
            .with("database.port", mysql.getPort())
            .with("database.user", mysql.getUsername())
            .with("database.password", mysql.getPassword())
            .with("database.dbname", mysql.getDbName())
            .with("database.include.list", String.join(",", mysql.getTables()))
            .with("include.schema.changes", "false")
            .with("database.server.id", "10181")
            .with("database.server.name", "customer-mysql-db-server")
            .with("database.history",
                    "io.debezium.relational.history.FileDatabaseHistory")
            .with("database.history.file.filename",
                    "/tmp/dbhistory.dat")
            .with("database.whitelist", "mysql.*")
            .with("offset.storage.file.filename", "/tmp/offsets.dat")
            .with("table.whitelist", "mysql.*")
            .build();
}

聯系:

executorService.submit(engine);

我希望名為handleEvent的方法在從 User 表中刪除數據時起作用,但事實並非如此。

我懷疑你的 mysql 連接器配置有問題。

  • .with("database.include.list", String.join(",", mysql.getTables())) :這應該是DB1,DB2格式(或者在你的情況下是mysql )。 或者你真的想為表列表配置,不是嗎? 所以應該是table.include.list=mysql.table1,mysql.table2
  • database.whitelistdatabase.whitelist在最近的 Debezium 版本中被刪除。 現在它們變成了database.include.listdatabase.exclude.list

希望這些要點可以幫到你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM