user674669
user674669

Reputation: 12392

Cleanly shutdown debezium connector for mysql

We have a Spring Boot java app using Debezium 2.4.0.Final.

We start Debezium thus:


@Component
public class Listener {
    private final DebeziumEngine<RecordChangeEvent<SourceRecord>> debeziumEngine;
   
    public Listener(Configuration eventsConnectorConfig) {
        this.debeziumEngine = DebeziumEngine.create(ChangeEventFormat.of(Connect.class))
                .using(eventsConnectorConfig.asProperties())
                .notifying(this::handleChangeEvent)
                .build();
    }

...

}

When the spring boot app shuts down, how do cleanly shutdown the Debezium connector? I took a look at DebeziumEngine class but couldn't find a method to stop/shut it down.

Thanks a lot!

Upvotes: 0

Views: 112

Answers (1)

user674669
user674669

Reputation: 12392

In your listener class, add a method:

@PreDestroy
private void stop() {
    if (debeziumEngine != null) {
        debeziumEngine.stop();
    }
}

I got this answer from https://groups.google.com/u/2/g/debezium/c/KeheEBDpixI

Upvotes: 0

Related Questions