I'm trying to connect Debezium to my Java code and expose the event messages in json format. I'm delivering this a a jar file which will be embedded into another application.
Here when I setup params and trying to initialize the Debezium with the DebeziumEngine.create(Json.class) method, a DebeziumException comes out with following message.
No implementation of Debezium engine builder was found
Following is my Java method:
private void setupDebezium() throws DebeziumException {
log.info("Setting up debezium");
//start debezium
final Properties props = new Properties();
props.setProperty("name", "engine");
props.setProperty("offset.storage", "org.apache.kafka.connect.storage.FileOffsetBackingStore");
props.setProperty("offset.storage.file.filename", "/Users/abc/mytemp1/offsets.dat");
props.setProperty("offset.flush.interval.ms", "1000");
/* begin connector properties */
props.setProperty("connector.class", "io.debezium.connector.mysql.MySqlConnector");
props.setProperty("database.hostname", "localhost");
props.setProperty("database.port", "3306");
props.setProperty("database.user", "root");
props.setProperty("database.password", "root");
props.setProperty("database.dbname", "students");
props.setProperty("database.server.id", "85744");
props.setProperty("topic.prefix", "my-app-connector");
props.setProperty("schema.history.internal",
"io.debezium.storage.file.history.FileSchemaHistory");
props.setProperty("schema.history.internal.file.filename",
"/Users/abc/mytemp1/schemahistory.dat");
try (DebeziumEngine<ChangeEvent<String, String>> engine = DebeziumEngine.create(Json.class)
.using(props)
.notifying(record -> {
System.out.println(record);
}).build()
) {
// Run the engine asynchronously ...
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(engine);
// Do something else or wait for a signal or an event
Thread.sleep(10000000);
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
Following are the Debezium dependencies used:
<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-api</artifactId>
<version>${version.debezium}</version>
</dependency>
<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-core</artifactId>
<version>${version.debezium}</version>
</dependency>
<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-embedded</artifactId>
<version>${version.debezium}</version>
</dependency>
<dependency>
<groupId>io.debezium</groupId>
<artifactId>debezium-connector-mysql</artifactId>
<version>${version.debezium}</version>
</dependency>
ps:
<version.debezium>2.1.4.Final</version.debezium>
What's wrong with my code?
The above issue happened when packing the Debezium into my source code. Root cause was that my source code was compatible with Java 11 while the corresponding Debezium version has been built on Java 17