Skip to content

Kafka Producer Consumer & Kafka Streams

Notifications You must be signed in to change notification settings

mauroreinehr/project80

 
 

Repository files navigation

Project 80

Spring Boot & Kafka

https://gitorko.github.io/spring-apache-kafka/

Version

Check version

$java --version
openjdk version "21.0.3" 2024-04-16 LTS

Kafka

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

Describe topic

docker exec -it kafkaserver /bin/bash
/opt/bitnami/kafka/bin/kafka-topics.sh --list --bootstrap-server localhost:9092
/opt/bitnami/kafka/bin/kafka-topics.sh --describe 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.

Open http://localhost:9090/

Dev

To run the code.

./gradlew clean build

./gradlew :kserver:build
./gradlew :kclient:build
./gradlew :kcommon:build
./gradlew :kstream:build

./gradlew :kserver:bootRun
./gradlew :kclient:bootRun
./gradlew :kstream:bootRun

About

Kafka Producer Consumer & Kafka Streams

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%