MysqlCDC数据获取代码
public static MySqlSource
String tab) {
Properties props = new Properties();
props.setProperty("useSSL", "false");
props.setProperty("allowPublicKeyRetrieval", "true");
MySqlSource
.hostname(Constant.MYSQL_HOST)
.port(Constant.MYSQL_PORT)
.databaseList(db) // set captured database, If you need to synchronize the whole database, Please set tableList to ".*".
.tableList(db + "." + tab) // set captured table
.username(Constant.MYSQL_USER_NAME)
.password(Constant.MYSQL_PASSWORD)
.jdbcProperties(props)
.deserializer(new JsonDebeziumDeserializationSchema()) // converts SourceRecord to JSON String
.startupOptions(StartupOptions.initial()) // 默认值: initial 第一次启动读取所有数据(快照), 然后通过 binlog 实时监控变化数据
.build();
return mySqlSource;
}

浙公网安备 33010602011771号