In this example, I will make the use of maxwell to raise an event when some records created/updated/delete and raised events will go to kafka and interested consumer will consume that event.

This is Maxwell’s daemon, an application that reads MySQL binlogs and writes row updates as JSON to Kafka, Kinesis, or other streaming platforms. Maxwell has low operational overhead, requiring nothing but mysql and a place to write to. Its common use cases include ETL, cache building/expiring, metrics collection, search indexing and inter-service communication. Maxwell gives you some of the benefits of event sourcing without having to re-architect your entire platform.

maxwell — user maxwell — password maxwell — producer=kafka — kafka.bootstrap.servers=localhost:9092 — kafka_topic=maxwell

593 [WARN] MaxwellConfig: maxwell mysql host not specified, defaulting to localhost

541731 [WARN] NetworkClient: [Producer clientId=producer-1] Error while fetching metadata with correlation id 8 : {maxwell=LEADER_NOT_AVAILABLE}

Source Code: https://github.com/javaHelper/Event-Driven-Architectures-for-Spring-Developers/blob/main/README.md

2022-08-22 15:12:37.389  INFO 11924 --- [currency1-0-C-1] com.example.consumer.KafkaConsumer       : === Rate: 1.0, KeyUSD
2022-08-22 15:12:37.389 INFO 11924 --- [currency1-0-C-1] com.example.consumer.KafkaConsumer : Currencies now: {USD=1.0}
2022-08-22 15:21:07.411 INFO 11924 --- [currency1-0-C-1] org.apache.kafka.clients.NetworkClient : [Consumer clientId=consumer-currency1-1, groupId=currency1] Node -1 disconnected.
2022-08-22 15:34:35.421 INFO 11924 --- [currency1-0-C-1] com.example.consumer.KafkaConsumer : === Rate: 0.782, KeyGBP
2022-08-22 15:34:35.421 INFO 11924 --- [currency1-0-C-1] com.example.consumer.KafkaConsumer : Currencies now: {GBP=0.782, USD=1.0}
2022-08-22 15:38:59.033 INFO 11924 --- [currency1-0-C-1] com.example.consumer.KafkaConsumer : === Rate: 0.8, KeyEUR
2022-08-22 15:38:59.034 INFO 11924 --- [currency1-0-C-1] com.example.consumer.KafkaConsumer : Currencies now: {EUR=0.8, GBP=0.782, USD=1.0}
2022-08-22 15:41:22.113 INFO 11924 --- [currency1-0-C-1] com.example.consumer.KafkaConsumer : === Rate: null, KeyEUR
2022-08-22 15:41:22.121 INFO 11924 --- [currency1-0-C-1] com.example.consumer.KafkaConsumer : Currencies now: {GBP=0.782, USD=1.0}

--

--

Prateek
Prateek

Written by Prateek

Java Developer and enthusiast

No responses yet