Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Kafka Connect With Springboot

I'm trying to find examples of kafka connect with springboot. It looks like there is no spring boot integration for kafka connect. Can some one point me in the right direction to be able to listen to changes on mysql db?

like image 585
user3310115 Avatar asked Dec 30 '18 00:12

user3310115


People also ask

How does Kafka listener work in Spring boot?

How does @KafkaListener work? The @KafkaListener is an annotation that marks a method or class as the target of incoming messages. By using @KafkaListener, you abstract away the need to configure the underlying KafkaMessageListenerContainer.


1 Answers

Kafka Connect doesn't really need Spring Boot because there is nothing for you to code for it, and it really works best when ran in distributed mode, as a cluster, not embedded within other (single-instance) applications. I suppose if you did want to do it, then you could copy relevent portions of the source code, but that of course isn't using Spring Boot, and you'd have to wire it all yourself

The framework itself consists of a few core Java dependencies that have already been written (Debezium or Confluent JDBC Connector, for your mysql example), and two config files. One for Kafka Connect to know the bootstrap servers, serializers, etc. and another for the actual MySQL connector. So, if you want to use Kafka Connect, run it by itself, then just write the consumer in the Spring app.

The alternatives to Kafka Connect itself would be to use Apache Camel within a Spring application (Spring Integration) or Spring Cloud Dataflow and interfacing with those Kafka "components" (which aren't using the Connect API, AFAIK)

Another option, specific for listening to MySQL, is to use Debezium Engine within your code.

like image 178
OneCricketeer Avatar answered Oct 05 '22 11:10

OneCricketeer