Spring Boot & Kafka
https://gitorko.github.io/spring-apache-kafka/
Check version
$java --version
openjdk 17.0.3 2022-04-19 LTS
To run kafka we need zookeeper, use the docker compose command to run kafka as a container
For windows ensure the C:\Windows\System32\drivers\etc\hosts file has these 2 entries. For link ensure /etc/hosts has these 2 entries.
127.0.0.1 zookeeper
127.0.0.1 kafkaserver
docker-compose -f docker/docker-compose.yml up
To create topic
docker exec -it kafkaserver /bin/bash
$ /opt/bitnami/kafka/bin/kafka-topics.sh --create --replication-factor 1 --partitions 1 --topic mytopic.000 --bootstrap-server localhost:9092
To delete topic
docker exec -it kafkaserver /bin/bash
$ /opt/bitnami/kafka/bin/kafka-topics.sh --delete --topic mytopic.000 --bootstrap-server localhost:9092
Clean up
docker-compose -f docker/docker-compose.yml stop
docker rm kafka-ui kafkaserver zookeeper
Restart
docker-compose -f docker/docker-compose.yml start
Dashboard for kafka, wait for a few seconds as it takes time to come up.