1. Kafka CLI: kafka-topics.sh
kafka-topics.sh
kafka-topics.sh --bootstrap-server localhost:9092 --list
kafka-topics.sh --bootstrap-server localhost:9092 --topic first_topic --create
kafka-topics.sh --bootstrap-server localhost:9092 --topic first_topic --create --partitions 3
kafka-topics.sh --bootstrap-server localhost:9092 --topic first_topic --create --partitions 3 --replication-factor 2
kafka-topics.sh --bootstrap-server localhost:9092 --topic first_topic --create --partitions 3 --replication-factor 1
kafka-topics.sh --bootstrap-server localhost:9092 --list
kafka-topics.sh --bootstrap-server localhost:9092 --topic first_topic --describe
kafka-topics.sh --bootstrap-server localhost:9092 --topic first_topic --delete
2. Kafka CLI: kafka-console-producer.sh
kafka-console-producer.sh
kafka-console-producer.sh --bootstrap-server localhost:9092 --topic first_topic
> Hello World
>My name is Conduktor
>I love Kafka
>^C (<- Ctrl + C is used to exit the producer)
kafka-console-producer.sh --bootstrap-server localhost:9092 --topic first_topic --producer-property acks=all
> some message that is acked
> just for fun
> fun learning!
kafka-console-producer.sh --bootstrap-server localhost:9092 --topic new_topic
> hello world!
kafka-topics.sh --bootstrap-server localhost:9092 --list
kafka-topics.sh --bootstrap-server localhost:9092 --topic new_topic --describe
kafka-console-producer.sh --bootstrap-server localhost:9092 --topic new_topic_2
hello again!
kafka-topics.sh --bootstrap-server localhost:9092 --list
kafka-topics.sh --bootstrap-server localhost:9092 --topic new_topic_2 --describe
kafka-console-producer --bootstrap-server localhost:9092 --topic first_topic --property parse.key=true --property key.separator=:
>example key:example value
>name:Stephane
3. Kafka CLI: kafka-console-consumer.sh
kafka-console-consumer.sh
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic first_topic
kafka-console-producer.sh --bootstrap-server localhost:9092 --topic first_topic
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic first_topic --from-beginning
kafka-console-consumer --bootstrap-server localhost:9092 --topic first_topic --formatter kafka.tools.DefaultMessageFormatter --property print.timestamp=true --property print.key=true --property print.value=true --from-beginning
4. CLI Consumer in Groups with kafka-console-consumer.sh
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic first_topic --group my-first-application
kafka-console-producer.sh --bootstrap-server localhost:9092 --topic first_topic
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic first_topic --group my-first-application
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic first_topic --group my-second-application --from-beginning
5. Consumer Group Management CLI kafka-consumer-groups.sh
kafka-consumer-groups.sh
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group my-second-application
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group my-first-application
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic first_topic --group my-first-application
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group my-first-application
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group console-consumer-10592
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic first_topic --group my-first-application
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group my-first-application
6. Consumer Groups -Reset Offsets kafka-consumer-groups.sh
kafka-consumer-groups
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group my-first-application --reset-offsets --to-earliest
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group my-first-application --reset-offsets --to-earliest --execute
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group my-first-application --reset-offsets --to-earliest --execute --topic first_topic
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic first_topic --group my-first-application
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group my-first-application
kafka-consumer-groups.sh
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group my-first-application --reset-offsets --shift-by 2 --execute --topic first_topic
kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group my-first-application --reset-offsets --shift-by -2 --execute --topic first_topic
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic first_topic --group my-first-application