Basic structure and examples to start with kafka to your projects.
Zookeeper(cluster), Kafka(cluster), Control Center and Kafka Topics Generator
Create Topic by command line
Access container:
docker exec -ti kafka-1 bash
Run command to create:
kafka-topics --create --bootstrap-server kafka-2:29092 --replication-factor 3 --partitions 3 --topic mytopic
Run command to list:
kafka-topics --list --bootstrap-server kafka-2:29092
Run command to show topic details:
kafka-topics --describe --bootstrap-server kafka-2:29092 --topic mytopic
Test Producer
by command line
Connect to topic:
kafka-console-producer --broker-list kafka-2:29092 --topic mytopic
Test Consumer
by command line
Connect to topic:
kafka-console-consumer --bootstrap-server kafka-2:29092 --topic mytopic
Connect to topic with Consumer Group:
kafka-console-consumer --bootstrap-server kafka-2:29092 --topic mytopic --from-beginning --group a
Show Consumer Group details:
kafka-consumer-groups --group a --bootstrap-server kafka-2:29092 --describe
Kafka Topics Generator
Will create topics on startup by using kafka console. kafka-topics
.
References: