如何在Java应用程序中嵌入debezium以捕获Oracle变更数据?

时间:2018-10-12 10:20:12

标签: oracle change-data-capture debezium

我正在Java应用程序中使用debezium来捕获来自Oracle 12c的更改。可以在localhost:1521上访问oracle数据库。下面是相应的Java代码。

    // Define the configuration for the embedded and Oracle connector ...
    Configuration config = Configuration.create()
            .with("connector.class", "io.debezium.connector.oracle.OracleConnector")
            .with("tasks.max", "1")
            .with("offset.storage",
                    "org.apache.kafka.connect.storage.FileOffsetBackingStore")
            .with("offset.storage.file.filename",
                    "/home/username/oracleLogs/offset.dat")
            .with("offset.flush.interval.ms", 10000)
            .with("name", "oracle-debezium-connector")
            .with("database.hostname", "localhost")
            .with("database.port", "1521")
            .with("database.user", "c##xstrm")
            .with("database.password", "xs")
            .with("database.sid", "ORCLCDB")
            .with("database.server.name", "oracle-debezium-server")
            .with("database.out.server.name", "dbzxout")
            .with("database.history",
                    "io.debezium.relational.history.FileDatabaseHistory")
            .with("database.history.file.filename",
                    "/home/username/oracleLogs/dbhistory.dat")
            .with("database.dbname", "ORCLCDB")
            .with("database.pdb.name", "ORCLPDB1")
            .build();

    // Create the engine with this configuration ...
    EmbeddedEngine engine = EmbeddedEngine.create()
            .using(config)
            .notifying(this::handleEvent)
            .build();

    // Run the engine asynchronously ...
    ExecutorService executor = Executors.newSingleThreadExecutor();
    executor.execute(engine);

请注意,Oracle数据库已按照给定here进行配置。从Oracle Instant Client获得的ojdbc8.jar和xstreams.jar也已导入到Java项目中。

执行上述代码时,即使关闭Oracle数据库,它也会产生以下输出。更改也不会被捕获。

28 [pool-1-thread-1] INFO org.apache.kafka.connect.storage.FileOffsetBackingStore  - Starting FileOffsetBackingStore with file /home/username/oracleLogs/offset.dat

我在这里做什么错了?

0 个答案:

没有答案